Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to edit breadcrumb ? #84

Open
dsnoeck opened this issue Feb 2, 2017 · 3 comments
Open

How to edit breadcrumb ? #84

dsnoeck opened this issue Feb 2, 2017 · 3 comments

Comments

@dsnoeck
Copy link

dsnoeck commented Feb 2, 2017

Hi, sorry it's me again ;-)

I want to edit the breadcrumb for the different pages I have created, but I don't find the way to do it.

It might be good to add it to the documentation.

BTW, your package is awesome, many thanks.

@sroutier
Copy link
Collaborator

sroutier commented Feb 3, 2017

Hello @dsnoeck,

Glad that you are finding the package helpful, that is why I created it and decided to release it open-source.

Yeah I have to work on the documentation! That giant readme is not great even when it has all the information.

At the moment the crumb trail is kinda static and automatically generated based on how the menu structure is defined and the current page viewed.

It's best explained with an example:

Given this partial menu:

MENU GRAPH        |   NODE NAME       | URL
----------------------------------------------------
\                     root              /
|- Admin              admin.container     
    | - Users         admin.users       /admin/users
    \ - Roles         admin.roles       /admin/roles

The bread crumb rendering is called in /resources/themes/default/partials/_body_content.blade.php with:

{!! MenuBuilder::renderBreadcrumbTrail(null, 'root', false)  !!}

The method signature is:

MenuHandlerTrait::renderBreadcrumbTrail( $leaf = null, $topNode = 'root', $includeTopNode = false )

So for all pages using the default theme, the leaf will be null or unspecified, the root will be root and the root node will not be rendered.

The root is the left most part of the trail and the leaf the right most part, so if a user clicks on the Roles link, one would expect the crumb trail to look as such: ```Admin > Role".

How does the system figures out the leaf when a null is passed? From the current request URL, it tries to find a match in the Menu definition.

This works for all items that are defined in the menu but, when the user clicks on the link to edit a role the URL no longer matches anything in the menu. So it's also possible to overwrite the leaf node with a session variable, that way in the Role controller one can set:

        session(['crumbtrail.leaf' => 'admin.roles']);

And every pages/views generated as a result of this controller will have the crumb trail "Admin > Role" otherwise if the leaf is not defined or deduced, the crumb trail is blank.

So currently the crumb trail is limited to rendering items that are defined in the menu only. There is no way to have a crumb trail like this "Admin > Role > Accountants > Edit", but in the future I want to allow this kind of functionality, I just have not had the time just yet.

I hope that this clarifies the crumb trail and menu system for you a little. Let me know if you have another questions.

Ciao.
/s

@dsnoeck
Copy link
Author

dsnoeck commented Mar 6, 2017

Hello @sroutier,

Thank you very much for the detailed response. Unfortunately, I needed a breadcrumb with more details. So, if I find the time to do it, I will submit a pull request.

I leave up to you to close or not this issue.

Cheers,
Damien

@sroutier
Copy link
Collaborator

sroutier commented Mar 7, 2017

Would love to have a good PR to make the breadcrumb more flexible and useful.
Ciao.
/S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants