ryan Posted December 9, 2016 Share Posted December 9, 2016 Lots of fun new upgrades to our Repeater and Repeater Matrix fields this week. In this post we cover all the details along with a couple of screenshots. You can start using these now in ProcessWire 3.0.44 (dev branch): https://processwire.com/blog/posts/pw-3.0.44-repeaters/ 14 Link to comment Share on other sites More sharing options...
asbjorn Posted December 10, 2016 Share Posted December 10, 2016 This is great. I was just looking for a way to nest repeaters a few weeks ago for a three level menu. My result was messy. But now I was able to do it better, with more options, easier editing and less code. Thank you for the time you are putting in to create this! I can see some future possibilities: Such as where the nesting depth level defines the width of repeater matrix items on the front end. Making it possible to create a dynamic template where each item can have a different column widths (Uikit or Bootstrap). It would eliminate the need to set the width as a value (or page field value). Making the back end a little more visual (good for the overview). Perhaps with flexbox in css on the front end … 1 Link to comment Share on other sites More sharing options...
bernhard Posted December 11, 2016 Share Posted December 11, 2016 hi ryan, nice updates as always! what do you think of adding the option to hide the label of the repeater item. that way you can use repeaters to setup reusable groups of fields. or do you see any drawbacks with this technique? Link to comment Share on other sites More sharing options...
LostKobrakai Posted December 11, 2016 Share Posted December 11, 2016 Can't this be done with the "skipLabel…" settings on inputfields? If not via the UI a Hook could add the setting. Link to comment Share on other sites More sharing options...
tpr Posted December 11, 2016 Share Posted December 11, 2016 If there's a CSS class that identifies that it's a one item only field then you can easily hide with CSS (eg admin.css with aos). 1 Link to comment Share on other sites More sharing options...
bernhard Posted December 11, 2016 Share Posted December 11, 2016 jep, there are data attributes <li class="Inputfield InputfieldRepeater Inputfield_address InputfieldItemList InputfieldRepeaterMax InputfieldRepeaterMin InputfieldColumnWidthFirst" id="wrap_Inputfield_address" data-page="1001" data-max="1" data-min="1" data-depth="0">[...]</li> would there be any drawbacks removing the label by default if it is min=1 and max=1 ? here's the field compared to the original: original: Link to comment Share on other sites More sharing options...
tpr Posted December 11, 2016 Share Posted December 11, 2016 1 hour ago, bernhard said: jep, there are data attributes <li class="Inputfield InputfieldRepeater Inputfield_address InputfieldItemList InputfieldRepeaterMax InputfieldRepeaterMin InputfieldColumnWidthFirst" id="wrap_Inputfield_address" data-page="1001" data-max="1" data-min="1" data-depth="0">[...]</li> Great - now you could target using ".InputfieldRepeater[data-min="1"][data-max="1"]" in your CSS. Be aware that you will need to set display: none, and also remove the padding on .InputfieldContent too. In this regard a hook would be better to add skipLabel (and setting field->label="" as skipLabel works only this case afaik) with PHP. 1 Link to comment Share on other sites More sharing options...
bernhard Posted December 11, 2016 Share Posted December 11, 2016 yeah, i know you can do all kinds of stuff in the admin. still i think it would be good to have a checkbox for that. there have been lots of people requesting such kind of field-groupings over the time and i think it would be better to solve that by providing a checkbox than letting people solve the problem all on their own and having no standard way of doing it (you can remove it by php, by css and also by js...). second best option would be to have it in AOS. maybe i find the time to file a PR next year for that... 1 Link to comment Share on other sites More sharing options...
fbg13 Posted January 14, 2017 Share Posted January 14, 2017 @ryan your function $depth = -1; foreach($page->repeater_items as $item) { if($item->depth > $depth) { echo "<ul>"; } else if($item->depth < $depth) { echo "</ul>"; } echo "<li>$item->title"; $depth = $item->depth; } while($depth--) echo "</ul>"; doesn't account for jumping more than 1 depth, when going from depth 3 to 0 it will output only one </ul> breaking the nesting. Maybe while($depth--) echo "</ul>"; was supposed to take care of that? For me it didn't actually change anything, that i could actually see. Here is how i "fixed" it: $depth = -1; foreach($page->repeater_items as $item) { if($item->depth > $depth) { echo "<ul>"; } else if($item->depth < $depth) { // changed from echo "</ul>"; echo str_repeat("</ul>", $depth - $item->depth); } echo "<li>$item->title"; $depth = $item->depth; } while($depth--) echo "</ul>"; 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now