I have a number of taxonomy settings with taxonomy context that work extremely well. I wanted, however, to alphabetize some of the taxonomy views with the views module and this seems to break the taxonomy context breadcrumb (although for some reason the rest of it works).
I had read somewhere to add the following code as an argument within the view to display the breadcrumb that is set within taxonomy context but it doesn't appear to work - or perhaps I'm doing something wrong. How can I get the breadcrumb I set within taxonomy context to show up with a taxonomy listing view instead of what views gives me which is incorrect.
if ($args[0]) {
$term = taxonomy_get_term($args[0]);
if ($term) {
$vocab = taxonomy_get_vocabulary($term->vid);
$arr_bc = array(
l(t('Home'), NULL),
l($vocab->name, 'taxonomy/vocabulary/' . $term->vid),
'<em>' . check_plain($term->name) . '</em>'
);
drupal_set_breadcrumb($arr_bc);
}
}
return $args;
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | taxonomy_context.module.patch | 2.42 KB | lee20 |
Comments
Comment #1
summit commentedSubscribing. Having similar issues with views using views argument.
greetings,
Martijn
Comment #2
lee20 commentedI found a fix for this issue reseting the breadcrumb after the view has been rendered by utilizing the hook_views_post_view() hook.
Note, that setting the views option for not including "Home" in the breadcrumb will always ignored.
I have tested this and it restores the breadcrumb for me. I don't think this should cause any side affects either.
The function looks something like this:
Attached is patch file that resolves this issue. It also implements static caching on taxonomy_context_get_breadcrumb to reduce processing as the function is invoked atleast twice on the term view page.
Comment #3
nedjoThanks. I haven't tested but the code looks good. The caching is a good improvement. Pls feel free to commit.
Comment #4
lee20 commentedComment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.