1

I want to add crumb/breadcrumb on each of search result item.

For example, if I search keyword "dog", the search result should return results as follow.


Dog's Life ($title)
Dog is life. Dog is love... ($snippet)
Home > Article > Dog's Life (the crumb)


Dog Dog Who's There ($title)
Who's there dog? Dog dog dog... ($snippet)
Home > Tips Trick > Dog dog Who's There (the crumb)


Usually I construct the crumb using variable $url from search_result.tpl.php via function mytemplate_preprocess_search_result(), implemented in template.php.

I create a new variable, $breadcrumb, based on variable $url and then I call it on search_result.tpl.php. Then I copy search_result.tpl.php into my theme folder.

The problem arises when it is no longer achievable to construct crumb from $url due to circumstances, mostly because of custom breadcrumb that is not related with URL.

Please guide me to achieve that goal, a different approach is welcome. Thanks.

1 Answer 1

1

If you already have a function to get breadcrumb from URL and assuming breadcrumb is, when is it, customize by hook_menu_breadcrumb_alter hooks, you just have to call this hook :

// Allow modules to alter the breadcrumb, if possible, as that is much
// faster than rebuilding an entirely new active trail.
drupal_alter('menu_breadcrumb', $active_trail, $item);

If this isn't enough to fix your problem, you can also see this contribution on github which seems great regarding the default breadcrumb construction in Drupal : https://gist.github.com/arshad/5490042#file-gistfile1-php-L12

Hope that helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.