How to add View arguments in view header?
pcave - December 8, 2008 - 15:17
| Project: | Views |
| Version: | 6.x-2.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | gildedgod |
| Status: | closed |
Jump to:
Description
How can I access the view arguments via PHP in the view header field in views 2 with Drupal 6?
Thanks!

#1
1. Add into index.php before "require_once './includes/bootstrap.inc';" your own variable:
<?php$my_own_argument = 1;
require_once './includes/bootstrap.inc';
?>
2. View -> Arguments -> Validator options -> Validator: PHP Code
3. View -> Arguments -> Validator options -> PHP argument code:
<?phpglobal $my_own_argument;
$my_own_argument = $argument;
return true;
?>
without "< ? php" and "? >"
4. View -> Header -> Input format: PHP Code
5. View -> Header -> Value:
<?phpglobal $my_own_argument;
echo "Your variable: ".$my_own_argument;
?>
There may be more accurate ways, but idea is the same)
#2
Or in the PHP in your header just use
$view = views_get_current_view()and check $view->args#3
Unfortunately this method didn't worked for me using views2 as CCK-field through Viewfield.
#4
And of course modifying core scripts for adding your variables is a bad idea =)
- this is just an example, for production sites you must find another way to add global variables :)
#5
Automatically closed -- issue fixed for two weeks with no activity.
#6
For future reference, Merlins method in #2 does work, even with ViewReference module