Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently I cannot show a complete menu trail with dynamic menu item count as I have to place the menu item and the parent and the parent of the parent (and so on) to the path breadcrumb settings. So as in the current dev version there is support for parent elements of terms, I will create a patch for integration of parents of node menu items.
Comment | File | Size | Author |
---|---|---|---|
#6 | path-breadcrumbs-add-support-for-node-menu-parents-2149763-6.patch | 4.58 KB | manuelBS |
#2 | path-breadcrumbs-add-support-for-node-menu-parents-2149763-1.patch | 2.92 KB | manuelBS |
Comments
Comment #1
SpleshkaLooking forward for you patch ;)
Comment #2
manuelBS CreditAttribution: manuelBS commentedHere we go ;-)
Comment #3
kalabromypage/%node/%referenced_node/photos/recent
. So I guess we can't just usemenu_get_active_trail()
with Node context. Instead we have to load menu according to given node (token_node_menu_link_load() as an example).Alternatively we can provide something like
%site:current-page:menu:pb-join:url
to clarify thatmenu_get_active_trail()
is used.node:menu-link:pb-join
.Comment #4
manuelBS CreditAttribution: manuelBS commentedOK I will implement this behaviour. Do you think we can use the function token_node_menu_link_load() and let PB in this case depend on the token module? Otherwise I have to copy the function to PB.
I think
is not an alternative but a nice addition. In this case we can handle the menu parents also of "none-node-pages". Do you have a hint how to add this as site:[...] is not an entity and in this case we cannot add new properties in the way we can with a node object.
Comment #5
Spleshka@Manuel,
I think you may copy the code from token module. No need to add an extra dependency because of few lines of code.
Comment #6
manuelBS CreditAttribution: manuelBS commentedI updated the patch. Please review again.
Comment #7
kalabroSounds great! :)
Why not? I suggest to add check is_callable/function_exists because PB doesn't require Token module. Token
"menu-link"
is provided by Token module (not by core or Entity Token), so it is quite clear that we need Token module enabled to use"node:menu-link:..."
. We also can add a note in docs/FAQ that"node:menu-link:pb-join:"
requires Token module.Entity API provides special site metadata: http://drupalcode.org/project/entity.git/blob/refs/heads/7.x-1.x:/module...
So Path Breadcrumbs UI can autocomplete %site tokens. Simple Token API can be also used but w/o autocomplete.
Comment #8
kalabroCould you please introduce "node:menu-link:pb-join:..." property, not "node:pb-join:..."? Maybe just as simple struct.
Also see my notes from #7.
There are minor code style errors in your patch (tabs instead of whitespaces, comment style, if statements and etc).
I will help with committing it in PB repo in next few days.
Comment #9
manuelBS CreditAttribution: manuelBS commentedOK two different opinions. Which one to follow in this case? ;-)
So what things are left to do:
1) use the token function if function exists (but what if not? Use a custom fucntion for that? in this case it makes no sence to copy the function just as fallback and try to call the other one if it exists)
2) Use entity metadata to to add properties for %site:current-page:menu:pb-join:url and show the active trail there as in the first version of the patch.
3) Do you want something to add?
Comment #10
Spleshka@kalabro,
But why do we need Token module and its :menu-link token? We may provide custom token so we can access all menu hierarchy like
node:pb-menu-join:name
andnode:pb-menu-join:url
. I'm not sure that we have to stick to the Token's code or behavior.The same with
site:current-page:pb-menu-join:name
andsite:current-page:pb-menu-join:url
. Doesn't it look more unified and independent from other code?Comment #11
kalabroWe don't need but we can successfully reuse its code base and well-known token "menu-link". See #1823030: Add ability to build the breadcrumb path based on menu hierarchy
For example:
Doesn't it look clear and consistent?
Comment #12
SpleshkaOkey, but what if Token module is disabled? Which tokens will be used for the same puproses as you described?
Comment #13
kalabroIf Token is disabled all %node:menu-link:... are not replaced (common behaviour for unknown tokens).
I don't mind to add one more custom pb-* token. It was just my opinion based on issue queue experience.
In case of #7 we can solve multiple tasks for different PB users:
1) Provide autocomplete for "menu-link" token (which is now not available)
2) Add new feature from this topic (complete menu trail)
3) Keep things simple for end user
Comment #14
kalabroIf we don't want to make user enable Token module for node menu hierarchy we can create our own implementation of token_node_menu_link_load() (as in #6), but still place :pb-join under "%node:menu-link:" so it will work with and without Token module.
So here are our tasks:
%node:menu-link:pb-join:...
" (with own _node_menu_link_load() function)%site:current-page:menu-link:pb-join:...
as in #2What do you think guys?
Comment #15
Spleshka100% agree. Lets implement this!
Comment #16
manuelBS CreditAttribution: manuelBS commented1) and 2) are already done, do you agree?
Only 3 and 4 are left. Where should the docu be written?
Comment #17
kalabroFinally!
1. Node token (no Token module required):
%node:menu-link:pb-join:name / %node:menu-link:pb-join:url / %node:menu-link:title
Implemented with Token API. Entity Property API is used only for autocomplete.
2. Current page menu (no Token module required):
%site:current-page:menu-link:pb-join:name / %site:current-page:menu-link:pb-join:url / %site:current-page:menu-link:title
3. Book module support (no autocompete yet):
%node:book:pb-join:name / %node:book:pb-join:url
Commit: http://drupalcode.org/project/path_breadcrumbs.git/commitdiff/b124741
Comment #18
SpleshkaWow, very cool! Thanks a lot!
Comment #19
kalabroThis feature is now in 7.x-3.0-beta7 release.
Docs in FAQ: https://drupal.org/node/2061955#menu-trail
Comment #20
manuelBS CreditAttribution: manuelBS commentedCool thanks for conmitting!