Jump to content

Breadcrumb Dropdowns


Robin S
 Share

Recommended Posts

7 hours ago, dragan said:

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}

I added support for this in v0.1.16

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Just tested the new feature in 0.1.16.  It worked great except I had to disable the MarkInPageTree module from https://github.com/benbyford/MarkInPageTree

I use that module to include the template name floated to the right of the Page name when viewing the Page Tree.

Ideally, I only want the MarkInPageTree's Page Tree modifications to only show when I'm on the Page Tree at /processwire/page/.

I've tried modifying the MarkInPageTree module's autoload key to the following:

using a selector string

'autoload' => 'id=3',

and using an anonymous function

'autoload' => function() {
              if((wire('page')->template == 'admin') && (wire('page')->id == 3)) return true;
                else return false; 
            },

as seen from 

Both didn't seem to work.  The labels on the Page Tree stopped showing on /processwire/page

Any idea of how I can get the MarkInPageTree module to only show when viewing the Page Tree on /processwire/page and not show in the breadcrumbs when the BreadcrumbDropdown module is enabled?  I also don't want the MarkInPageTree module to show when the sidebar is opened and the Page Tree is displayed when clicking on the tree icon.

 

 

  • Like 1
Link to comment
Share on other sites

13 minutes ago, gmclelland said:

Any idea of how I can get the MarkInPageTree module to only show when viewing the Page Tree on /processwire/page and not show in the breadcrumbs when the BreadcrumbDropdown module is enabled?

In v0.1.17 I call the label method so hooks are not triggered - please update and report back if you're still experiencing issues.

  • Like 1
Link to comment
Share on other sites

@gmclelland With AOS PageListTweaks you can add "{title} [em.my-template-class]{template.name}[/em]" to a template's "List of fields to display in the admin Page list" and they are shown only in the page tree and not in the breadcrumb dropdown. Note that this requires editing every template so it may not be the one you need.

image.png.3b8ba44180298b2eafb20e452dc57be3.png

@Robin S

I have some pages without title and they show up in the breadcrumb menu like this:

image.png.096dd7e78db63efb2578363fd6ebc213.png

I know it's not a common thing but apparently PW saves the page even if you don't fill the title, so the page name could be added as a fallback ($page->get('title|name')). Perhaps such pages could be surrounded with eg. square brackets to indicate that it's the name and not the title.

  • Like 2
Link to comment
Share on other sites

Thanks @tpr and @Robin S!  Your module update **very quickly** fixes the immediate problem with the breadcrumb trails and breadcrumb dropdown menu items when used with the MarkUpPageTree module.

A little off topic to this thread now, but I would still like to modify the MarkUpPageTree module to only operate on the Page Tree on /processwire/page/.  Do you know of any way to do that?  Maybe only somehow autoload on page id = 3 or something like that? 

This is what I want to prevent.  In the picture you can see the MarkUpPageTree module showing the template names in Page Tree Side Panel.  I really only want to show that on /processwire/page/

pagetree.thumb.jpg.21dd3441a171e5d28693a9fd46a338a2.jpg

 

Link to comment
Share on other sites

So it seems like both Page Trees (the one at /processwire/pages/ and the one shown in the picture above) have an id = 3.  So I guess you would somehow have to determine if the page is displayed in some kind of modal or not and then apply the hook or MarkUpPageTree?  Does that sound right or even doable?

Link to comment
Share on other sites

57 minutes ago, tpr said:

so the page name could be added as a fallback ($page->get('title|name')).

Thanks, added in v0.1.18

57 minutes ago, tpr said:

Perhaps such pages could be surrounded with eg. square brackets to indicate that it's the name and not the title.

I understand your thinking here, but I think it's clearest if Breadcrumb Dropdowns keeps to the conventions of the page labels in Page List as much as possible, and Page List falls back to the page name without adding square brackets.

  • Like 2
Link to comment
Share on other sites

  • 1 month later...
8 hours ago, adrian said:

would you be willing to add support for User pages (ProcessUser) as well please?

I have added support for this in v0.1.19.

The scenario of editing user pages is a different kettle of fish than "normal" pages because you are then outside the structure of what are normally considered editable pages. So there isn't much that's useful in the dropdowns apart from the last dropdown.

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

Thanks @flydev, but that solution feels less than ideal - I think there is a better way. If you want to implement the AdminThemeUikit breadcrumbs in your custom theme (which you would have to in order for the Breadcrumb Dropdowns module to work) then you can just call AdminThemeUikit::renderBreadcrumbs() because it is a public method.

So in your custom theme template files where you want to output the breadcrumbs you can do something like this:

echo $modules->get('AdminThemeUikit')->renderBreadcrumbs();

 

Edited by Robin S
typo
  • Thanks 1
Link to comment
Share on other sites

Thanks @Robin S I see,

anyway I just tested to call this function, it works fine on ProcessPageEdit but when I switch to, for example, on a ProcessModule (a config module page) the breadcrumbs isn't rendered :

<!-- MAIN CONTENT -->
	<main id='main' class='pw-container uk-container uk-container-expand uk-margin uk-margin-large-bottom'>
		<div class='pw-content' id='content'>

			<div class="uk-breadcrumbs">
				<?php if ($layout != 'sidenav' && $layout != 'modal') echo $modules->get('AdminThemeUikit')->renderBreadcrumbs(); // echo $adminTheme->renderBreadcrumbs(); ?>
			</div>
          
[...]

 

Result on ProcessPageEdit :

1595557160_Capturedecran2019-05-23a09_23_57.png.ab46ff33eae896ea9ee1bc51108ae302.png

Result on ProcessModule (Breadcrumbs's module config page) :

807590720_Capturedecran2019-05-23a09_23_11.png.96b3ded81da04542092adbcfaa40a070.png

Edited by flydev
typo
Link to comment
Share on other sites

3 hours ago, flydev said:

when I switch to, for example, on a ProcessModule (a config module page) the breadcrumbs isn't rendered

Ah right, unfortunately AdminThemeUikit::renderBreadcrumbs() returns early unless some protected class properties are set, and there is no setter method provided.

It's a shame that AdminThemeUikit wasn't designed with flexibility for customisation in mind, because it means that users like yourself have to create a totally separate theme that duplicates almost the entirety of the AdminThemeUikit code just to achieve a few minor changes. It would have been nice if something like Markup Regions could have been employed in the theme template files.

But it looks like there's no better way for now, so I've merged your PR.

  • Like 2
Link to comment
Share on other sites

  • 8 months later...
  • 10 months later...

v0.2.0 released, which is a fairly major refactoring of the module with some new features. There are now dropdowns in ProcessTemplate and ProcessField that allow you to quickly jump from editing one template/field to another.

2020-12-18_134833.png.9b004886e8a02cd006747fc756aef11a.png

There are config options to disable these new dropdowns if you don't want them for some reason, and options to exclude system templates/fields from the dropdowns.

2020-12-18_135021.png.c810c294e9f79f1b54f1c10ee5ed9b74.png

The update is available directly from GitHub but unfortunately I am locked out from editing this module in the directory (I've emailed @ryan about it) so v0.2.0 won't show up there until the next automatic update runs.

  • Like 8
Link to comment
Share on other sites

Thanks @Robin S - fantastic as always.

I wonder if I can ask a little favour and have it support languages as well? And while you're at it, is there any reason not to also support Setup > Logs and have you thought about Access > Users / Roles / Permissions? I think these would also be useful if you can't see any downsides.

  • Like 2
Link to comment
Share on other sites

8 minutes ago, adrian said:

I wonder if I can ask a little favour and have it support languages as well? And while you're at it, is there any reason not to also support Setup > Logs and have you thought about Access > Users / Roles / Permissions? I think these would also be useful if you can't see any downsides.

Access > Users is already supported as a variation of Page Edit. For the other ones you mentioned if they were to be supported I'd want to do that as some generic method that uses the flyout menu JSON. I'll take a look at that in the new year.

  • Like 1
Link to comment
Share on other sites

5 hours ago, Robin S said:

Access > Users is already supported as a variation of Page Edit.

Yes of course - sorry, I forgot you added that already. My natural instinct these days is go to the Breadcrumbs first in most cases which is why it's always so weird when they're not available - going to be great having these available for templates, fields, and some of these others in the future. Thanks again!

Link to comment
Share on other sites

  • 2 weeks later...

Hi @Robin S

Since the last update (0.2.0) I get this exception when I set a custom hook :

Fatal Error: Uncaught TypeError: Argument 1 passed to BreadcrumbDropdowns::pageEditBreadcrumbs() must be an instance of AdminThemeUikit, instance of AdminThemeCanvas given, called in site/modules/BreadcrumbDropdowns/BreadcrumbDropdowns.module on line 117 and defined in site/modules/BreadcrumbDropdowns/BreadcrumbDropdowns.module:221

#0 site/modules/BreadcrumbDropdowns/BreadcrumbDropdowns.module (117): BreadcrumbDropdowns->pageEditBreadcrumbs(Object(AdminThemeCanvas))
#1 wire/core/Wire.php (397): BreadcrumbDropdowns->modifyBreadcrumbs(Object(HookEvent))
#2 wire/core/WireHooks.php (927): Wire->_callMethod('modifyBreadcrum...', Array)
#3 wire/core/Wire.php (465): WireHooks->runHooks(Object(AdminThem (line 221 of site/modules/BreadcrumbDropdowns/BreadcrumbDropdowns.module)

This error message was shown because: you are logged in as a Superuser. Error has been logged.

 

Sorry I didn't got the time to investigate. I am using the custom theme AdminThemeCanvas.

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