PHP code is not working for Custom Breadcrumbs module
vj0914 - June 19, 2008 - 18:55
I am using custom breadcrumbs to customize breadcrumbs on my site.
When I use "Breadcrumbs visibility" section with php code, my breadcrumbs disappear.
here is what I did:
<?php
if ( arg(0) == 'products' ) {
return TRUE;
}
?>Am I doing right? much appreciated if anyone can give me a hint.

The arg() function ignores
The arg() function ignores aliases and returns original drupal paths (like node/nnn or taxonomy/term/nnn or admin/user etc). What is 'products'?
It may be a view, or a
It may be a view, or a custom path created by module
the products just a URL
the products just a URL aliases I give to the URL.
so you think I should use original path?
Test
Do you try to display the return value of arg(0) ?
As said cog.rusty, Drupal interprets the alias URL and I am not sure you obtain the result you wish
I found an alternative way
I found an alternative way to get URL component,
here is what I did:
"\$path = \$_SERVER['REQUEST_URI']; list(\$arg1, \$arg2, \$arg3, \$arg4) = split('/', \$path); \$arg1 == 'products';"
since I am using Custom Breadcrumbs, above code will be inside eval() to determine if "products" is in the url arguments.
for example, if the url is www.site.com/products, then the breadcrumbs will be displayed, otherwise it will not. But right now it's not working yet.
Try this then
Try this then:
<?php
$path = trim($_GET['q'], '/');
$path = drupal_get_path_alias($path);
$path = explode('/', $path);
if ( $path[0] == 'products' ) {
return TRUE;
}
?>
Thanks a lot cog.rusty, you
Thanks a lot cog.rusty, you are my man.
I copied and pasted your code there, and it is working like charm. Thank you so much
Also thanks all people who have helped me on this issue.
Hopefully placing this post
Hopefully placing this post here isn't bad etiquette. I am having a very similar problem to the original poster...
I am trying to have a different custom breadcrumb display for different languages. For example for the Spanish breadcrumb I put the following in the breadcrumb visibility field:
<?php
global $language;
if (($language->name)=='Spanish') {
return TRUE;
}
?>
The idea is that the breadcrumb (specified but not reproduced here) only shows on the Spanish pages of my site.
Similar PHP code seems to have the desired outcome in normal posts I have tested with so I can't understand why this isn't working. I suspect it is something quite obvious. After several hours trying to see where I am going wrong I could do with a hint, if anyone is reading this...