[term] not displaying in Title

locomo - June 1, 2009 - 04:35
Project:Custom Breadcrumbs
Version:6.x-2.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

Hi

I'm trying to make a custom breadcrumb for a CCK nodetype - but I can't get anything to display for [term] or [term-raw].... strangely [termpath] and [termalias] both work

here's what i have - am I missing something or doing something wrong?

Title:
Business Directory
[term]

Path:
business-directory
[termalias]

#1

MGN - June 2, 2009 - 05:28
Status:active» postponed (maintainer needs more info)

It doesn't look like you are doing anything wrong in setting up the custom_breadcrumb. The fact that termpath works and term doesn't makes me think that this may be a pathauto problem. If you set up a similar breadcrumb for a standard content type like a page, or a story, do you have the same problem, or is it only for the custom type?

#2

locomo - June 2, 2009 - 06:00

Yeah - i created a test taxonomy for type Page and the [term] token works fine.

When you say it might be a pathauto problem do you mean a conflict with how I'm using pathauto or a conflict with Custom Breadcrumbs?

Thanks for getting back to me!

#3

MGN - June 2, 2009 - 14:31

I don't think its a pathauto problem anymore, since [term] is actually supplied by the token module, while [termpath] is supplied by pathauto.

And I don't think its a Custom_breadcrumbs problem either, since cb just uses the available tokens, it doesn't create or alter them.

Also, I guess I should just verify that you are setting up a node-type breadcrumb in custom breadcrumbs, and not one of the other types (views, paths, or taxonomy).

If you are not getting a replacement for [term] in your breadcrumb then it seems like $node->taxonomy isn't defined for some reason. Are [term-id], [vocab-raw], [vocab] or [vocab-id] returning anything?

I guess I would also try modifying the custom breadcrumb to use some of the other node-type tokens (like [title] and [nid], for example), just to make sure they are returning correctly.

#4

MGN - July 11, 2009 - 15:57
Status:postponed (maintainer needs more info)» closed

Closing this, given the long time without a response. Reopen if its still an issue.

#5

heyyo - November 8, 2009 - 21:19
Status:closed» active

same error here...

In a custom BC for a nodetype:
[termpath] [termalias] [nid] [title] are working but not [vocab-raw], [vocab] or [vocab-id] [term] [term-id]

Sorry to reopen this issue...

#6

MGN - November 8, 2009 - 22:07

More detail is required to troubleshoot this.

I just tried these tokens on a forum page and they worked just fine. Since all of these are node-type tokens, if some work and others do not, its not a custom breadcrumbs issue. Custom breadcrumbs just calls the token_replace_multiple() function to replace the tokens - the same for all tokens. If there was a problem in custom breadcrumbs it would affect all tokens of a given type, not just a handful.

It sounds like the taxonomy information is not being loaded into the node object for some reason? But without more information I can only speculate, and again, its not really a custom breadcrumbs issue. Still, I will help if I can.

#7

heyyo - November 9, 2009 - 11:37

It's strange those tokens on the same nodetype are working for pathauto. Please have a look to my website. I have no idea what I can provide you for more debugging.

http://imart.hsh.co.il/painting/dan-groover/pop-art/keith-haring

#8

MGN - November 9, 2009 - 19:16

@heyyo, what are you putting in for the titles and paths fields for this custom breadcrumb? And what type of page is this? Is it a custom node type, or is it provided by a contrib module?

It looks like [vocab-discipline-term-raw], and [vocab-style-term-raw] ? shouldn't these really be [vocab-raw], or have you created your own tokens?

#9

heyyo - November 9, 2009 - 21:26

For this specific node page:

This a custom BC for a custom nodetype artwork: (regular CCK field)

Titles:
[vocab-discipline-term-raw]
[author-name-raw]
[vocab-style-term-raw]
[title-raw]

Paths:
[vocab-discipline-term-raw]
user/[author-uid]
[vocab-discipline-term-raw]/[vocab-style-term-raw]
[vocab-discipline-term-raw]/[vocab-style-term-raw]/[title-raw]

All artwork's nodes have 2 taxonomies: discipline(Painting, Sculpture) and style (pop-art, street-art, wood, metal...)
Those token [vocab-discipline-term-raw], and [vocab-style-term-raw] come with the non official module "Token for Vocabularies":
http://drupal.org/node/185446#comment-1480398

But I don't think the bug is related to this module because I have the same problem on an other nodetype:
http://imart.hsh.co.il/events/painting/street-art/live-painting-sukkah-wall

In this nodetype I don't use those vocab tokens from this module.

Look at the path on the word Street Art it's empty it should be events/[term-id]

Titles:
Events
[termalias]
[title-raw]

Paths:
events
events/[term-id]
node/[nid]

Modules related to taxonomy that I use :

Taxonomy Node
Taxonomy redirect
Term Display
Token for Vocabularies (the one we spoke about)
Taxonomy Menu

#10

MGN - November 10, 2009 - 01:28

Does this only happen with this nodetype? or does it happen with every custom node type?

I did the following on a test site and everything worked fine.

1. create a new content type
2. add a custom field to the new type
3. add the content type to two different vocabularies
4. create new content with this content type, selecting taxonomy terms for each vocabulary and filling in the custom field
5. create a custom breadcrumb for this new node type, using [termalias] [vocab] [term-id] and [vocab-id] tokens in paths and titles section.
6. View the new content
7. Breadcrumb displays as expected.

I tried this with all of the custom breadcrumbs submodules enabled, and again with only the base custom breadcrumbs module. Both worked as expected.

If there is some crucial step that I am missing, please let me know. Note that I am not using any of those modules that you have listed on my test site, so you might try disabling them one at a time and see if that changes the token replacement.

You might also want to indicate what custom breadcrumbs submodules you are using, and what configuration options you have set.

#11

MGN - November 10, 2009 - 01:39
Status:active» postponed (maintainer needs more info)

#12

heyyo - November 10, 2009 - 07:21

Thanks for all the time you worked on my bug.

I found it :-)

I did the same test as yours on a fresh acquia install, and like your test it was working. So I added the modules related to taxonomy, and by chance the first one was responsible :-)

The winner is:

Term Display

To reproduce the bug

1 activate the module term Display http://drupal.org/project/term_display
2 go to content/taxonomy/edit/vocabulary/1
3 In section

Display options
Set display options on content view for terms in this vocabulary.
Display style:

Choose list or custom or "load into $node object"

4 do the same for vocab 2
5 see the result on the BC it's empty !!!

Now I have no idea how to fix this...help is really welcome...

#13

MGN - November 10, 2009 - 17:53

Glad you found it, but I am afraid I don't know anything about the Term Display module. I would recommend opening a new support request in the Term Display issue queue, and refer back to this conversation. I'll leave this open, just in case someone has experience with Term Display and can help.

#14

MGN - November 16, 2009 - 00:07
Status:postponed (maintainer needs more info)» active

#15

heyyo - November 16, 2009 - 09:55

Here the answer in Term Display forum:

http://drupal.org/node/628960

#16

MGN - November 16, 2009 - 15:13

Thanks for the update. I am not sure this makes sense, but you can try it and see if it works for you.

custom_breadcrumbs_nodeapi used to use 'view' up until about a year ago when it was changed for compatibility with other modules. I am afraid changing it back may break that compatibility.

See #300316: Use nodeapi op 'alter' rather than 'view' to allow usage with panels content pane for details. From the discussion there, I am afraid that if you change 'alter' to 'view' you'll create a problem for tokens that rely on cck fields.

#17

heyyo - November 16, 2009 - 16:26

I have applied the revert patch, and for the moment the 2 nodetypes where I had problems work correctly :-)

http://imart.hsh.co.il/painting/dan-groover/pop-art/keith-haring
http://imart.hsh.co.il/events/painting/street-art/live-painting-sukkah-wall

Thanks MGN

I will keep you informed if this patch breaks another part with CBC.

Line 159
function custom_breadcrumbs_nodeapi($node, $op, $teaser, $page) {
if ($op == 'view' && empty($teaser) && !empty($page)) {
// Check for breadcrumb for this node type.
global $language;
$languages = array('language' => $language->language, 'all' => '');
$breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs', NULL, array('node_type' => $node->type), $languages);
if (!empty($breadcrumbs)) {
$objs = array('node' => $node);
if ($breadcrumb = custom_breadcrumbs_select_breadcrumb($breadcrumbs, $objs)) {
custom_breadcrumbs_set_breadcrumb($breadcrumb, $objs);
}
}
}
}

/**
* Implementation of hook_form_alter().
*/
function custom_breadcrumbs_form_alter(&$form, $form_state, $form_id) {
// Provide custom breadcrumbs for comment forms associated with nodes.
if ($form_id == 'comment_form' && isset($form['nid']['#value'])) {
$node = node_load($form['nid']['#value']);
// Call custom_breadcrumbs_nodeapi to provide a custom_breadcrumb for this comment.
custom_breadcrumbs_nodeapi($node, 'view', array(), array(1));
}

#18

MGN - November 17, 2009 - 02:12
Category:bug report» support request
Status:active» won't fix

Ok. Now I see why this works, but its really a hack/workaround and not a good solution for custom breadcrumbs.

Here is what is happening. Term Display is deleting (unsetting) the taxonomy data from the node object (by design) during the hook_nodeapi view operation. By doing this, the taxonomy data is no longer available for modules like custom breadcrumbs that use the alter operation. The following code snippet is from term_display_nodeapi function:

<?php
foreach ($node->taxonomy as $tid => $term) {
  if (
$term->vid == $vocabulary->vid) {
    switch (
$term_display_data['style']) {
      case
TERM_DISPLAY_LIST:
      case
TERM_DISPLAY_LOAD:
      case
TERM_DISPLAY_CUSTOM:
       
$terms[$tid] = $term;
   
// Fall through.
     
case TERM_DISPLAY_NONE:
     unset(
$node->taxonomy[$tid]);
    break;
    }
  }
}
?>

Since it has been deleted from the node object, the token replacement fails.

Switching custom breadcrumbs to use the nodeapi 'view' operation works around this problem by doing the token replacement in the breadcrumb before Term Display has a chance to delete it. This works only because custom_breadcrumbs_nodeapi happens to be called before term_display_nodeapi. Note that other modules could use the nodeapi view operation to add information to the node, and this information should also be available to custom breadcrumbs, but only if custom breadcrumbs_nodeapi triggers on the 'alter' operation, since 'alter' happens after 'view'.

The Term Display module removes the taxonomy term data from the node, so its by design. A more satisfactory workaround would be to develop term display tokens that could be used in custom breadcrumbs. This way we don't run the risk of breaking normal behavior.

 
 

Drupal is a registered trademark of Dries Buytaert.