Maintaining the breadcrumb trail in a view?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
kirilius's picture

Here is the situation:

I have a node type called Destination. I have created a view called Destination Pictures, which shows all pictures from a given destination.
Using the following code I have added this view as a new tab under the main Destination node type:

<?php
function dest_pics_menu($may_cache) {
 
 
$items = array();

  if (
arg(0) == 'node' && is_numeric(arg(1))) {
     
$node = node_load(arg(1));
      if (
$node->nid && $node->type=="destination") {
        
$items[]= array(
         
'path' => 'node/'. arg(1) .'/dest_pics',
         
'title' => t('Destination Pictures'),
         
'callback' => 'send_to_dest_pic_page',
         
'callback arguments' => array(arg(1)),
         
'type' => MENU_LOCAL_TASK,
         
'weight' => 10
       
);
      }
    }

    return
$items;
 
}

function
send_to_dest_pic_page($parent_nid) {
 
   
drupal_goto($path = "node/". $parent_nid ."/dest_pics");
     
}
?>

Note that the new tab and the view have the same path: node/[nid]/pictures. I am not sure if that really matters. Please let me know if it does.

My ultimate goal is to make this view an integral part of the Destination node. Therefore it should have the same title as the node it is attached to as well as the same breadcrumb trail.

So now when I am viewing a Destination node, I have 3 tabs: View, Edit and Destination Pictures. The top of the node page looks like this:

(Breadcrumb trail) Home
MY NODE TITLE | View | Edit | Destination Pictures

I need my view to have the same title as the calling node. To have a dynamic title for the view I am using the following piece of code in the argument handling section:

<?php
if (arg(0) && is_numeric(arg(1))) {
 
$node = node_load(arg(1));
 
$view->page_title = $node->title;
}
return
$args;
?>

This way the title remains unchanged when I click in the Destination Pictures tab.
Please let me know if what I am doing here is right or if that's the best way of doing it since I am a very new Drupal-coder ;-)

So when I click the Destination Pictures tab, my view is displayed, the title is the right one (taken from the calling node) but the breadcrumb is strange:

(Breadcrumb trail) Home > MY NODE TITLE
MY NODE TITLE | View | Edit | Destination Pictures

First of all I would like to preserve the same breadcrumb as it is in the node itself. In this case it should say just "Home". Second the URL it is pointing to is not valid: http://mysite/node/%24arg/dest_pics - the argument placeholder is not replaced with a real [nid].

Can you give me some advice on how can I control the breadcrumb for a view dynamically? Also I am not sure that I am following the right path to achieve what I described in the beginning. Any help will be appreciated...

Thanks!

Comments

Hi, any ideas?

kirilius's picture

Hi, any ideas?

Custom Breadcrumb Revamp

RobLoach's picture

You should have a look at my proposal regarding custom_breadcrumbs here: http://drupal.org/node/215475 .

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: