I have a node type called Inventory; it's a monster. Lots of cck fields and taxonomy terms. I have several views in the secondary menu and I would like to create a back link to them from the node; based on the top taxonomy term. The top level views are mutually exclusive, thus a one to one relationship.

Example Breadcrumb
Home >> Top Level View On Menu, Displaying Top Term >> Node
or even this
Home >> Top Level View On Menu, Displaying Top Term

when viewing a node inside of inventory.

So far I have a Triggered Rule called Breadcrumbs.
Event: Content is going to be viewed.
Condition: Node has type -> Inventory
Actions: Set Breadcrumb
Titles:

Test A
Test B

Paths:

park-models
park-models/new

So when I go to view a node that has a path park-models/new/chariot-eagle-west-e-109 which is made via these tokens [field_type-term]/[field_condition-term]/[title-raw] all I get in the breadcrumbs is Home. What am I doing wrong?

CommentFileSizeAuthor
#12 breadcrumbs.JPG138.89 KBandersonmh
#11 rules.panels2-hack.inc_.zip1.07 KBmuka

Comments

amitaibu’s picture

Component: User interface » Documentation
Status: Active » Postponed (maintainer needs more info)

I think you are not using the token's prefix. Look at the token replacement list - every token has a 'prefix' which is the argument it is taken from.

mikeytown2’s picture

Right now tokens are only used for auto Path/Title generation.

If I change it to this
Titles:
[node:title]

Paths:
node/[node:nid]

Still no go.

mikeytown2’s picture

Title: Set Breadcrumb - Help » Set Breadcrumb when using Panels -> node/%

Been testing and the problem involves Panels. If you override the node with panels, breadcrumbs via rules doesn't work. Breadcrumbs do work with panels if you use Menu Breadcrumb, and have a menu set for each item.

Steps to have panels take over nodes
Enable Panel pages
Page Title: %node
Path: node/%
Arguments: Add Node ID

Is this a wait and see, or do I need to ditch panels to get Breadcrumbs set by rules working?

amitaibu’s picture

I think panels has it's own implementation of breadcrumbs, so it might be overriding your breadcrumbs.
Two things that come into mind are:
1) Check if there's an option in panels to disable it's breadcrumbs.
2) Try making the Rules module weight (in the {system} table) heavier.

mikeytown2’s picture

Opened an issue in Panels
http://drupal.org/node/364280

Took a peek at Menu Breadcrumbs, since it works.

/**
 * Implementation of hook_init().
 */
function menu_breadcrumb_init() {
  if (variable_get('menu_breadcrumb_determine_menu', 1)) {
    $menu_item = menu_get_item();
    $menu_link = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $menu_item['href'])));
    $use_menu = $menu_link['menu_name'];
    menu_set_active_menu_name($use_menu);
  }

  $breadcrumb = drupal_get_breadcrumb();
  
  if (variable_get('menu_breadcrumb_append_node_title', 0) == 1) {
    if (variable_get('menu_breadcrumb_append_node_url', 0) == 1) {
      $breadcrumb[] = l(drupal_get_title(), $_GET['q']);
    }
    else {
      $breadcrumb[] = drupal_get_title();
    }
  }
    
  if (count($breadcrumb) == 1 && variable_get('menu_breadcrumb_hide_on_single_item', 0)) {
    $breadcrumb = array();
  }
    
  drupal_set_breadcrumb($breadcrumb);
}

Here's the code in system.rules.inc

/**
 * Action Implementation: Set breadcrumb.
 */
function rules_action_set_breadcrumb($settings) {
  $titles = explode("\n", $settings['titles']);
  $paths = explode("\n", $settings['paths']);

  $trail = array(l(t('Home'), ''));
  for ($i = 0; $i < count($titles); $i++) {
    // Skip empty titles
    if ($title = trim($titles[$i])) {
      // Output plaintext instead of a link if there is a title
      // without a path.
      $path = trim($paths[$i]);
      if (strlen($path) > 0 && $path != '<none>') {
        $trail[] = l($title, trim($paths[$i]));
      }
      else {
        $trail[] = check_plain($title);
      }
    }
  }
  drupal_set_breadcrumb($trail);
}

Looks like menu_breadcrumb_init() always get's called, thats why it grabs the breadcrumb $breadcrumb = drupal_get_breadcrumb(); So no matter what, it re saves the breadcrumb. What if Rules had a similar hook for the breadcrumb, to get around issues like this one?

fago’s picture

hm, what's the difference here? Does panels overwrite the breadcrumb?

I don't think there is a bug in rules, but if you can determine a more robust way to set breadcrumb, go for it!

mikeytown2’s picture

Panels doesn't invoke the NodeAPI if your only using CCK fields. Panels sets up a pseudo node when using node/%.
Rules could benefit if it used hook_init() instead of hook_nodeapi(), thus it would work on any page; not just nodes.

fago’s picture

Status: Postponed (maintainer needs more info) » Fixed

you can do so by using the according event from System, A page is being viewed or so,

mikeytown2’s picture

@fago

Sweet, Thanks!!!

Status: Fixed » Closed (fixed)

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

muka’s picture

Issue tags: +Panels2, +breadcrumbs, +rules
StatusFileSize
new1.07 KB

Sorry, this issue is closed.. but someone solved with node/% breadcrumb issue ?

If I use the system "A page is viewed" I got as unavailable Content has type ( Unavailable argument: Content )

so tried with php condition

$node_type = "prodotto";
// is a std node view ?
if(   (  arg(0)=='node' && is_numeric(arg(1)) && !arg(2) ) ){
  $node = node_load(arg(1));
  return ($node->type == $node_type) ? TRUE : FALSE;
}
return false;

but token replacement for node doesn't work, so php again (i want url as prodotti/taxonomy_t/node_name in breadcrumb)

TITLES:

Prodotti

$node = node_load(arg(1));
$term = array_shift($node->taxonomy);

echo $term->name."\n".$node->title

PATHS:
prodotti

$node = node_load(arg(1));
$term = array_shift($node->taxonomy);
echo "taxonomy/term/".$term->tid."\n"."node/".$node->nid;

Is this the right approach?
Attached a file with some functions I've worte, useful to display the panels path in breadcrumb with custom functions trought the php of Rules. More info in the file.

Thanks.

ps oops. the attachment need the < ?php opening tag at the first line.

andersonmh’s picture

StatusFileSize
new138.89 KB

+1 or subscribe, however the protocol is used. I have a similar situation that I foolishly sent to the Rules discussion group. As @muka described, I have the same issue: If I use the system "A page is viewed" I got as unavailable Content has type ( Unavailable argument: Content ). My original post:
http://groups.drupal.org/node/19615

Why can't I get "Content Type = "what ever"?