Jump to content

repeater inside itself


diogo
 Share

Recommended Posts

Greetings,

Funny, I was just thinking today about doing some stress tests on ProcessWire just to learn what would happen in various scenarios. A repeater in its own repeater is definitely a good stress test!

How about using the API to run a loop that creates a new page from random strings as long as the number of pages returns a count > 0?

Wow, I'm getting a flashback to nights in my college dorm room hanging out with friends -- looking into a video camera hooked up to a television aimed at the television screen.

Thanks,

Matthew

Link to comment
Share on other sites

and all that just because I caught the wrong thread.

No worries Martin. Your original question is still very valid. Has anyone else tested this - is it still possible to add repeater inside another repeater in latest dev version?

Link to comment
Share on other sites

You can't put a repeater field inside another repeater field at present. Perhaps we'll be able to do that in the future, but I'm not yet sure how to support that. I did test it out at one point, but it seemed to be very problematic with some fieldtypes. 

Link to comment
Share on other sites

ah, i see. thanks guys. I followed the discussions about but haven`t found anything concrete that it`s no longer possible. It would be a nice feature, even in a limited way, so please see it as an feature-request from my side. say you have a page "team" with repeater "members". it would be very easy to add 1 picture for each member and have free defineable meta-info-combinations for lable/value to input data like interests, phone, email  in a repeater "member_infos".  this can make such things pretty comfortable for clients to administrate. But I see the problems in massive usage on the other side.

thanks,

martin

Link to comment
Share on other sites

ah, i see. thanks guys. I followed the discussions about but haven`t found anything concrete that it`s no longer possible. It would be a nice feature, even in a limited way, so please see it as an feature-request from my side. say you have a page "team" with repeater "members". it would be very easy to add 1 picture for each member and have free defineable meta-info-combinations for lable/value to input data like interests, phone, email  in a repeater "member_infos".  this can make such things pretty comfortable for clients to administrate. But I see the problems in massive usage on the other side.

thanks,

martin

I have been thinking that simple "key=value" fieldtype would be great, with nice JS-powered inputfield to having nice UI. Repeater is (imo) overkill for that kind of stuff... and in the otherhand just having textarea with this:

interests=movies, internet

phone=1234678

is lacking in UI-wise.

Link to comment
Share on other sites

@martijn ... the team>member situation is just an example for a kind of table data, nothing user specific. key-value fields as apeisa says and as we do it all with the repeater field ... at least outside of a repeater field :-)

@apeisa ...something like this would be nice for the images field too. but I think,  this is also discussed in another thread.

@diogo ... sure. but it needs a few steps to add a new member-page where a reapeater field lets you do all that in one step. clients love it.

Link to comment
Share on other sites

  • 2 weeks later...

OK. I'm confused.  For the record is it true you cannot put Repeater B into Repeater A?

I'm developing a site for a restaurant and the repeater field is perfect for doing a menu. Each menu item can have the title, writeup and price field maybe even with an optional image in a repeater so they (the owners) can add, delete or rearrange menu items easily.

However, certain menu items such as Garlic Bread have multiple variants: half order, half order with cheese, full order, full order with cheese each with it's own price point. I thought, for ease, it would be great to add a variant repeater to the menu item repeater so that different variations of an item could be added, or deleted with a simple click. Is that possible or is it not possible?

I could make each variant a separate menu item but that seems like a less elegant solution. As does using a textarea and just writing everything out.

Alright then, re-read thread and Ryan's last seems to confirm you shouldn't put a repeater in a different repeater. I would like to second the request for this. There are uses for it. I'll figure something else out.

Edited by digitex
Link to comment
Share on other sites

OK. I'm confused.  For the record is it true you cannot put Repeater B into Repeater A?

This is true. It's not currently possible. I understand there are some good use cases for supporting one level of repeaters within repeaters, so I'll be on the lookout for a way to support it. But for now, the best route to take for the use case you mentioned is to do it with pages instead of repeaters. Though in your case, I think the textarea option might be a good one since you only need a key and value. You could enter the variants like this: 

5.99=Half order

6.50=Half order with cheese

9.50=Full order with cheese

On your front-end, you could work with it like this:

$variations = array();
foreach(explode("\n", $item->variations) as $line) {
  list($price, $label) = explode("=", trim($line));
  // you could output the variations right here
  echo "<li>$label: $price</li>";
  // or you could stuff them into an array for later use, like this:
  $variations[$label] = $price;  
}

// how you might output the array, if preferred
echo "<table>";
foreach($variations as $label => $price) {
  echo "<tr><td>$label</td><td>$price</td></tr>";
}
echo "</table>";
 
  • Like 2
Link to comment
Share on other sites

You are so much better at this than I am. Oddly, I understand what you've done. 6 months ago i wouldn't have been able to say that. You're schoolin' me. Even so, I would never have thought of doing that on my own.

It's a great solution as long as I make sure they understand the importance of maintaining the format price=label. They're pretty savvy so that shouldn't be a problem.

Thanks Ryan. I owe you again. Tell me where to send it and I'll ship you some Canadian beer.

  • Like 1
Link to comment
Share on other sites

 Tell me where to send it and I'll ship you some Canadian beer.

Please send a cold keg of Unibroue La Fin Du Monde, and I'll have my tap ready.   :biggrin:  Just kidding, but that's one of my top 3 beers and has been for a long time. Canadians know how to make some damn fine beer, that's for sure. Luckily it's easy to get around here. A good thing, because Georgia has some kind of laws about shipping beer (to protect the poor beer/wine distributors). 

beer-chugger.gif

  • Like 3
Link to comment
Share on other sites

  • 3 years later...

old topic i know but the title fits exactly so...

i would love to request "repeater inside itself" again and would suggest to limit it to one level...

i'm actually building something using repeater matrix but guess that doesn't matter too much for this (might be wrong)
so you could have one matrix type which has one field (itself, field is called "content") when you then use this field in page editor and create a new matrix item of type content...you won't be able to add another content item inside of it but only all other types

that would be awesome for building flexible columns without cluttering each item with a whole load of fields..

EDIT: okay my fault...i knew there is is depth already and i played a little with it..and i'm sure i'll get it working using depth ;)

EDIT2: think i got it now :)

Edited by Can
Link to comment
Share on other sites

  • 5 years later...
On 2/20/2013 at 5:11 AM, apeisa said:

No worries Martin. Your original question is still very valid. Has anyone else tested this - is it still possible to add repeater inside another repeater in latest dev version?

No. I just did it in v 3.0.184 and ran into recursion hell. Glad I always use VMs.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...