views:

445

answers:

2

I am using the node id as an argument in a drupal view. However, I want the title of the view to display the title of the node.

For example, I have a node with node-id 36 and title "Hello World". The views page url is "example.com/display-node/36" (36 being the node-id passed as an argument). I want the title of the page displayed as "Page: Hello World". How do I do that?

Thanks!

+2  A: 

insert in Header views php code:

$node = menu_get_object();
drupal_set_title('Page: '.$node->title);
Nikit
A: 

It took me a while to figure out answer one to this question; so here is a more detailed explanation...

  1. You must have the PHP Filter module enabled (admin/build/modules).
  2. In your page view (admin/build/views/edit/[your view name]) click on header under Basic Settings
  3. Place the following in the text box that pops up:
    <?php
    $view = views_get_current_view();
    // [0] is first arg, [1] is second etc.
    //My first argument is a Node:Nid argument to get the node id from the url.
    $node = node_load($view->args[0]);
    drupal_set_title('Page: '. $node->title);
    ?>
    
  4. Expand the Input Format section and select PHP Code:
  5. Click update and the title should now display properly!

I hope this helps! ~God bless!

Robert Fleming

related questions