I'm not sure this is a feature request or bug.
In my path alias i have an expanded taxonomy tree and som additional fields. I could not really find a token that represented a parent taxonomy term so I went for the code way.
1. The fields for Titles and Paths in the custom_breadcrumbs table are only 255 chars long. Making it a bit short for scripts.
2. The php is evaluated when creating the breadcrumb configuration. There is no node object available at that point resulting in the breadcrumb validation failing.
I was able to work around it, but I think this should be adressed.
Here is my code: (Not pretty, and not optimized)

Titles:
$ph=drupal_get_path_alias('node/'. $node->nid);$pts=explode('/', $ph);$titles = array('sko', '', '[term-raw]', '[field_merke-title-raw]', '[field_fargegruppe-raw]');$titles[1] = $pts[1]; return $titles;

Paths:
$ph=drupal_get_path_alias('node/'. $node->nid);$pts=explode('/', $ph);foreach ($pts as $pt){$p.='/'.$pt;$paths[]=$p;}array_pop($paths); if (!$node) $paths= array('','','','',''); return $paths;

Comments

MGN’s picture

255 characters is short for a script. If you need more than this, save your code as a custom function elsewhere and call this function within the paths and/or title fields. This is a quick-and-dirty advanced feature that most users will not need (it would be much cleaner just to spend the time building reliable and reusable tokens), so I am not too concerned about its limitations.

I agree there can be problems in validating some php. Perhaps it would be better not to try when a php snippet is included? Just trying to avoid breaking the site whenever possible...

Thanks for the feedback!

sauce71’s picture

Thanks for the reply. I'll put it in a separate function when time permits. I guess I must put it in a module to make it available when the script executes. But then if I need a module, I can just as well use nodeapi and drupal_set_breadcrumb :)

MGN’s picture

Status: Active » Fixed

That is the beauty of Drupal!

Of course you don't really need a separate module for this. Usually sites have site-specific code (or hacks) that are kept in include files (or a site-specific module), so you can just add it to your collection of hacks. If necessary remember to add a require_once(...) statement to include the function before using it.

For portability, you might consider creating a token and adding the code your sites tokenSTARTER module...

sauce71’s picture

I got a module for my common hacks and usually make a site specific module for site hacks. I probably look into tokenStarter some day. The beatuy of opensource as well is that you can usually find som starting code. I found that this does most of what i need.
http://api.ubercart.org/api/function/uc_catalog_nodeapi/2.0

Status: Fixed » Closed (fixed)

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