Hi
I am confused on how to present a Title that is representative of a prepared Path; whereby the value used within Path's % args will not be the presented value used by the Title.
For example, let's say I have a content type Project that is represented by Project ID 65 and a Project Name "Build Bridge". Every Project has a set of Tasks, and each Task maintains its relation to a Project with a database field task_project_id.
I have got the basics down on how to use Views' arguments:
- I define an argument for %1 argument to refer to task_project_id, which has a views_handler_argument_numeric defined within Task's hook_views_data().
- I define a path /project/%/tasks.
- This works great in finding all the tasks for a project based upon filtering upon task_project_id
Now I want to set up the Argument Title. Instead of using the Project ID within this Title, referred to by %1, I want to use Project Name to represent the path Project ID. It is not clear to me how to do this.
I thought may be "Argument Handling code" would help, http://drupal.org/node/70145, but it does appear to exist in Views 2.
How can this be done?
Thanks
Jeff in Seattle

Comments
Solved using views_get_current_view()
I found a work-around using Drupal functions
views_get_current_view()anddrupal_set_title().Inserting the following PHP code within Header set for "Input Format: PHP Code:
<?php
$view = views_get_current_view();
$args = $view->args;
$task_project_id = $args[0]; // %1
$project_name = __custom_function_get_project_name(task_project_id
$title = 'Tasks of Project "'. $project_name.'"';
drupal_set_title($title);
?>
Thanks
Jeff in Seattle
Thanks - that helped!
Thanks - that helped!
...or implement
...or implement title_query() in your handler...
taken from views_handler_argument_node_nid.inc
<?php
/**
* Override the behavior of title(). Get the title of the node.
*/
function title_query() {
$titles = array();
$placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
$result = db_query("SELECT n.title FROM {node} n WHERE n.nid IN ($placeholders)", $this->value);
while ($term = db_fetch_object($result)) {
$titles[] = check_plain($term->title);
}
return $titles;
}
?>
View Header PHP - set title with argument
In your view, click Header. Put this (with input format: php):
<?php$view = views_get_current_view();
$node = node_load($view->args[0]); // args[0] will get %1 node id
drupal_set_title($node->title); // set node title as view title
?>
User name + text for the title...
So I have got this far using devel and what i've picked up from some video's and:
Posted by brian.lewis on February 7, 2012 at 5:46am
In your view, click Header. Put this (with input format: php):
<?php$view = views_get_current_view();
$node = node_load($view->args[0]); // args[0] will get %1 node id
drupal_set_title($node->title); // set node title as view title
?>
And i made this
<?php$view = views_get_current_view();
$node = node_load($view->args[0]); // args[0] will get %1 node id
drupal_set_title($node->name); // set node author name as view title
?>
This gets me the Author name in the title but what i really want is author name + some text... I'd be extremely grateful for any pointers :)
Here is my first ever bit of
Here is my first ever bit of php with the help of these pages:
<?php$view = views_get_current_view();
$node = node_load($view->args[0]); // args[0] will get %1 node id
drupal_set_title(t('@title my custom text', array('@title' => $node->name))); // set node author name and custom text as view title
?>
Hope it helps others....