I need to make Breakcrumb visible on some pages of content type.

Please help me out in putting php code which make the breakcrumb visible for:

Node id: 17
or
Node title: Journals.

Thanks a lot

Comments

MGN’s picture

In the breadcrumb visibility box, you can insert php code that returns TRUE (show breadcrumb) or FALSE (don't show breadcrumb). You have access to the $node variable, so in this case the following would work for you:

return ($node->nid == 17) ? TRUE : FALSE;

EDIT:
this is easier:

return ($node->nid == 17);

pushkarpathak’s picture

Thanks MGN! It worked.

pushkarpathak’s picture

Title: Breadcrumb visibility: php code help » Breadcrumb visibility: php code help for View

MGN, one more help.

In custom breadcrumbs it is required to specify node type? What is node type of a View? I have a View which is Contents page of journal World Today. I had put its node type as World Today.

When I didn't specified any condition and did for all page of node type "World Today", it comes in all article page but not in Contents page.

What should I put to breakcrumb specifically for View page (Contents in my case)?

Thanks in advance

MGN’s picture

Views is not support in 6.x-1.4 (except by this patch http://drupal.org/node/323816#comment-1082064). But this feature has now been added (as an optional submodule) in custom breadcrumbs 6.x-2.x-dev.

pushkarpathak’s picture

Thanks MGN!

But I am finding it very complicated to install patch to server. I am using a shared-hosting. Do you have any Tip which can help me in this?

MGN’s picture

If you need views support, I would just install custom breadcrumbs 6.x-2.x-dev. If you have problems, that code will be supported whereas the patch will not. This may get around the problem that you are having, but its good to figure out how to install patches on your server as well. The handbook pages at http://drupal.org/patch/apply should help.

MGN’s picture

Status: Active » Fixed

Marking this as fixed since the original question has been answered.

Status: Fixed » Closed (fixed)

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

vdewar’s picture

return ($node->nid == 17);
Someone should add this into the documentation as an example of the Breadcrumb visibility use. I have been searching all over for just an example.
Since the Node Type on the Custom Breadcrumbs admin page just says "[type] with PHP snippet
I would also recommend users adding a comment /*to say what they are targeting*/, until a field is provided for a custom name

gellpak’s picture

I second this. Took me an hour on google and this site to figure this out.

Jsan2020’s picture

What is not clear to me is whether you can use the tokens in the "Breadcrumb visibility" field. I am trying to check the node path to only override the breadcrumb on specific pages within a content type. Does anyone have an example for doing this?

MGN’s picture

@Jsan2020 - no in the breadcrumb visibility field you have to write valid php (there isn't a token replacement phase). You do have access to the node object.

Please open a new support request since yours doesn't appear to be related to the original issue and people don't always review closed issues...

thamas’s picture

Just for the record. One can use this method to support i18n (multilanguage sites).

For example to show the custom breadcrumb just for Hungarian nodes, write:
return ($node->language == hu);

You can set multiple breadcrumbs for the same node type, and use dedicated language visibylity settings in each.
(Tested with 7.x-1.0-alpha1.)