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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Spleshka’s picture

Looking forward for you patch ;)

manuelBS’s picture

Status: Needs work » Needs review
FileSize
2.92 KB

Here we go ;-)

kalabro’s picture

Status: Needs review » Needs work
Related issues: +#1823030: Add ability to build the breadcrumb path based on menu hierarchy
  1. %node context can be used not only on node pages (node/%node). Imagine something like mypage/%node/%referenced_node/photos/recent. So I guess we can't just use menu_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 that menu_get_active_trail() is used.
  2. I personally suggest to use consistently pb-join token in this manner: node:menu-link:pb-join.
manuelBS’s picture

OK 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

%site:current-page:menu:pb-join:url

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.

Spleshka’s picture

@Manuel,

I think you may copy the code from token module. No need to add an extra dependency because of few lines of code.

manuelBS’s picture

Status: Needs work » Needs review
FileSize
4.58 KB

I updated the patch. Please review again.

kalabro’s picture

OK I will implement this behaviour.

Sounds great! :)

Do you think we can use the function token_node_menu_link_load()

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.

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.

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.

kalabro’s picture

Status: Needs review » Needs work

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

manuelBS’s picture

OK 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?

Spleshka’s picture

@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 and node: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 and site:current-page:pb-menu-join:url. Doesn't it look more unified and independent from other code?

kalabro’s picture

But why do we need Token module and its

We 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:

  • %site:name - %site:url
  • %node:menu-link:pb-join:name - %node:menu-link:pb-join:url
  • %node:menu-link:title - %node:menu-link:url
  • %node:field-category:pb-join:name - %node:field-category:pb-join:url

Doesn't it look clear and consistent?

Spleshka’s picture

Okey, but what if Token module is disabled? Which tokens will be used for the same puproses as you described?

kalabro’s picture

If 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

kalabro’s picture

If 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:

  1. Provide "menu-link" simple structure for nodes
  2. Implement "%node:menu-link:pb-join:..." (with own _node_menu_link_load() function)
  3. Add %site:current-page:menu-link:pb-join:... as in #2
  4. Write docs.

What do you think guys?

Spleshka’s picture

100% agree. Lets implement this!

manuelBS’s picture

1) and 2) are already done, do you agree?
Only 3 and 4 are left. Where should the docu be written?

kalabro’s picture

Status: Needs work » Needs review

Finally!

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

Spleshka’s picture

Wow, very cool! Thanks a lot!

kalabro’s picture

Status: Needs review » Fixed

This feature is now in 7.x-3.0-beta7 release.
Docs in FAQ: https://drupal.org/node/2061955#menu-trail

manuelBS’s picture

Cool thanks for conmitting!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.