Posts Tagged ‘Drupal’
Drupal Custom Breadcrumb visibility PHP code
I needed to show a custom breadcrumb on specific pages by URL.
The nodes in question were of “page” content type.
The URLs of these nodes were like:
/green
/green/page1
/green/page2
/green/page3 and so on.
I only wanted the custom breadcrumb to show up on:
/green/page1
/green/page2
/green/page3
and not on /green
I created a breadcrumb with title “Green” and path “green” and used this PHP code for visibility:
$p= explode('/', $_REQUEST['q']); return ($p[0] == 'green' && $node->nid != 79);
where 79 is the Node ID of the /green page.
I was able to get the desired result!
Note to self: print_r statements are your friend
Debugging a Drupal theme this early morning and remembered that using a print_r statement can provide all of the variables in a debug format for you.
print_r(explode('/', $alias));