When setting items to "nolink" they still appear in the breadcrumb trail with an tag (linking to "nolink").

The breadcrumb functions need to be overwritten to either remove (hide) the nolink/separator display, or render the text with like it does in the menu.

Maybe include an option in the admin so you can choose to hide completely, or remove the link for greater control.

Comments

mariano.barcia’s picture

Version: 6.x-1.3 » 6.x-1.5
Component: Miscellaneous » Code
Status: Active » Needs review
StatusFileSize
new1.31 KB

I checked out the code, and there is a hook_init() with the code addressing this issue. However, it did not seem to have any effect on the breadcrumb building, so I moved it to hook_nodeapi() and it's now working. Attaching a patch for revision. HTH, salud.

marcoka’s picture

tested, not making a difference here. but i think the problem is with the menutrails module, because that uses drupal_set_breadcrumb, too

andyf’s picture

Similar patch here. I used the view op, and left the processing in hook_init() as well in case there are pages that don't invoke the view op. Also modified the install file to give it a higher weight.

Btw specific problem was using it with menutrails, but the patch should work for other modules that play with the breadcrumb in the same way.

nclavaud’s picture

Could not apply the patch. I had to do it manually.

Anyway, it didn't work for me. _special_menu_items_process_breadcrumb() gets called and works fine, but I still see nolink links in the breadcrumb (though I have checked the module weight in database and flushed all caches).

I have a couple of functions that get called after _special_menu_items_process_breadcrumb(), and particularly this menutrails_views_pre_view() that rebuild the nolink link... :-|

drupal_set_breadcrumb() called by drupal_get_breadcrumb()
drupal_set_breadcrumb() called by menu_breadcrumb_init()
drupal_set_breadcrumb() called by drupal_get_breadcrumb()
drupal_set_breadcrumb() called by _special_menu_items_process_breadcrumb()
drupal_set_breadcrumb() called by menutrails_views_pre_view()
drupal_set_breadcrumb() called by drupal_get_breadcrumb()

andyf’s picture

@nclavaud which patch did you try? Have you tried adding a hook_views_pre_view() to this module and just putting in _special_menu_items_process_breadcrumb()?

nclavaud’s picture

@AndyF : I was talking about patch #3, and yes, I ended up doing what you suggest (implementing hook_views_pre_view() in special_menu_items) and it solved my problem :-)

andyf’s picture

Cool. It's not elegant, but at least it works :) Would you be able to make a patch and add it to this issue?

gagarine’s picture

Status: Needs review » Needs work

Don't think using node_api for this job is a good idea hook_views_pre_view is a better idea.

retiredpro’s picture

@nclavaud, How did you add those functions to the module? I tried manually patching from #3 and then adding this extra few lines to special_menu_items.module

function hook_views_pre_view() {
_special_menu_items_process_breadcrumb();
}

duaelfr’s picture

StatusFileSize
new1.43 KB

There is the same issue on the 7.x branch
Here is a patch which could be backported to 6.X version and which fixes the issue elegantly

gagarine’s picture

Status: Needs work » Active

committed on D7 dev. I keep it active for D6 but the backport will certainly have to change more stuff to make it works.

juampynr’s picture

Version: 6.x-1.5 » 7.x-1.x-dev
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new722 bytes

I still see this issue in the dev branch of 7.x. It happens that the l() core function calls url() when generating the path, thus encoding it to '%3Cnolink%3E'. This makes that the statement at special_menu_items_init() does not match and the crumb is printed as a link.

Attached is a patch that fixes the issue.

Related: #1394442: Breadcrumbs link is still active after setting <nolink> to a menu item

jax’s picture

Status: Closed (fixed) » Needs review

IMO hook_init() is way too soon to do this. I'd move this to hook_process_breadcrumb() which is as late as possible.

jax’s picture

My solution:

function mymodule_process_breadcrumb(&$variables) {
  $tag = variable_get('special_menu_items_nolink_tag', '<span>');
  $crumb = special_menu_items_render_menu_item($tag, '$1');
  $variables['breadcrumb'] = preg_replace('@<a[^>]+%3Cnolink%3E[^>]+>([^<]+)</a>@', $crumb, $variables['breadcrumb']);
}
miaoulafrite’s picture

allright gentlemen

i found out something that may be useful for you.
in case we have a item, i link it in the breadcrumb to its parent via a theme function

<?php
function YOURTHEME_process_page(&$variables) {
	// Add support for the breadcrumb : nolinks would be still available leading to 404
	$item = menu_get_item();
	$trail = menu_get_active_trail();
	foreach ($trail as $key => $value) {
		if($trail[$key]['href'] == '<nolink>') $trail[$key]['href'] = $trail[$parent]['href'];
		$parent = $key;
	}
	menu_set_active_trail($trail);
  	drupal_alter('menu_breadcrumb', $trail, $item);
	$variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => menu_get_active_breadcrumb()));
}
?>
juampynr’s picture

Emailed the maintainer. This has been active for far too long.

gagarine’s picture

Status: Needs review » Needs work

Thanks for the patch #12.

It need to be redone for the last .dev. with those small change.

+++ b/special_menu_items.module
@@ -198,7 +198,7 @@ function special_menu_items_init() {
+    if (strlen(strstr($crumb, url('<nolink>'))) > 0) {

instead of using url use check_plain to avoid a DB query. Do this work *before* the loop and store in a variable so you dont do a check_plain for each links.

+++ b/special_menu_items.module
@@ -256,4 +256,4 @@ function special_menu_items_menu_link_update($link) {
\ No newline at end of file

Add a new line

juampynr’s picture

I cannot reproduce this error anymore :(

Used drupal 7.14 and fresh clone of branch 7.x-1.x-dev of Special Menu Items module.

Is anyone still experiencing this problem? If not, this can be marked as fixed.

gagarine’s picture

Status: Needs work » Fixed

So let's mark it as fixed. Other changes perhaps had fixed that.

Of course feel free to reopen.

Status: Fixed » Closed (fixed)

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

yashadev’s picture

Version: 7.x-1.x-dev » 7.x-1.0
Status: Needs review » Active

I still have this problem using 7.x-1.0. Can this be commited to 1.0 as well please?

gagarine’s picture

Status: Active » Closed (fixed)

Use the dev.