Jump to content

Breadcrumb Dropdowns


Robin S
 Share

Recommended Posts

  • 3 weeks later...

Hey Robin - I am really loving this module - it's becoming one of my key navigation tools, so thank you!

This might be feature creep so I definitely won't mind if you don't think this is a good idea, but I was thinking an "Add New" link at the top of each list could be quite useful.

  • Like 2
Link to comment
Share on other sites

On 9/11/2018 at 9:50 AM, adrian said:

any reason why the find siblings method doesn't use "include=all" ?

Yes, it was an oversight.

As more states need to be indicated in the dropdown items it gets harder to come up with distinguishable and tasteful styles for all of them. I think the hidden and unpublished pages need to use the same styling as in Page List, so that means I've had to change the styling for uneditable pages - these are now indicated by italics and reduced opacity (and the "not-allowed" cursor for devices that support hover).

Other changes introduced in v0.1.7:

  • The dropdowns now take $page->listable into account, so non-listable pages do not appear in the dropdowns.
  • There is now a hookable BreadcrumbDropdowns::getSiblings method in case anyone wants to override the listed siblings for a page. This won't be needed in most cases though.
  • Like 1
Link to comment
Share on other sites

Just had another thought ?

For pages with more than 25 siblings, I wonder if it would be worth putting the current page in the middle of the list of options, with 12 before and 12 after. At the moment, if the page being edited is beyond the first 25 it doesn't show in the list and so there is no way to access pages on either side of the current one.

I think this is fairly efficient:

    public function ___getSiblings($page) {
        $numSiblings = $page->parent->numChildren();
        $start = $numSiblings > 25 ? ($page->index - 12 > 0 ? $page->index - 12 : 0) : 0;
        while($numSiblings - $start < 25) $start--;
        $siblings = $page->siblings("start=$start, limit=25, include=all");
        $siblings->filter("listable=1");
        return $siblings;
    }

Instead of this where you can't see page "27" in the list:

image.png.b4e28caaec0dc30e45adfc267a39b311.png

 

you now get this with it right in the middle:

image.png.c6c9b15b78002df51899b53a7fee42dc.png

 

You probably need to do some more testing to make sure there are no issues with sorting. Maybe the selector needs: sort=sort

Did some testing here and it seems to be working great.

 

  • Like 4
Link to comment
Share on other sites

5 minutes ago, Robin S said:

v0.1.10 released. Fulfilling a request by @adrian, if the currently edited page has children or the user may add children, a caret at the end of the breadcrumbs reveals a dropdown of up to the first 25 children and/or an "Add New" link.

2018-09-14_122245.png.c96005626bae59aacdf75b21e77f5c18.png

 

Awesome - thank you!

Link to comment
Share on other sites

  • 1 month later...

v0.1.11 released.

Thanks to a pull request from @adrian, this update wraps the last breadcrumb item in a link to the page tree (like the other breadcrumb items) and also standardises the page tree links so they always include an "open" parameter to load the tree opened to the clicked page. This is a change from the core breadcrumbs, which treats the link on parent breadcrumb item differently. There is discussion on this topic here: https://github.com/processwire/processwire-issues/issues/22

My opinion is that the breadcrumb tree links should be treated consistently, and if you want to go back to the page tree in its last state you can click the ProcessWire logo or "Pages" or "Pages > Tree" in the main admin menus.

  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

Hey @Robin S - looks like there is a bug when you're editing an unpublished page - it ends up messing up the $start value for the siblings selector so I end up with a list of pages that are nowhere near the page I am editing.

Let me know if you can't reproduce and I'll see if I can figure out the problem later.

Link to comment
Share on other sites

22 minutes ago, adrian said:

Hey @Robin S - looks like there is a bug when you're editing an unpublished page - it ends up messing up the $start value for the siblings selector so I end up with a list of pages that are nowhere near the page I am editing

Thanks, seems like a core issue with Page::index(): https://github.com/processwire/processwire-issues/issues/751

Will see if I can find a workaround for the short term.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

@Robin S Thanks a lot for this module.

Is it possible to show also custom page list names?

i.e. if I define in my template to use certain fields for page list

{title} {client_name} {pl_active_only} {year}

(edit template > tab "advanced")

I still only see the default title being displayed.

  • 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

×
×
  • Create New...