Jump to content

PW 3.0.44 core updates


ryan
 Share

Recommended Posts

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 …

  • Like 1
Link to comment
Share on other sites

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:

2016-12-11 11_49_57-Edit Page_ About • repeater.dev.png

original:

2016-12-11 13_04_28-Edit Page_ About • repeater.dev.png

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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...

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

@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>";

 

  • Like 1
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...