Download & Extend

How to add View arguments in view header?

Project:Views
Version:6.x-2.1
Component:Code
Category:support request
Priority:normal
Assigned:gildedgod
Status:closed (fixed)

Issue Summary

How can I access the view arguments via PHP in the view header field in views 2 with Drupal 6?

Thanks!

Comments

#1

Assigned to:Anonymous» gildedgod
Status:active» fixed

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:
<?php
global $my_own_argument;
$my_own_argument = $argument;
return
true;
?>

without "< ? php" and "? >"
4. View -> Header -> Input format: PHP Code
5. View -> Header -> Value:
<?php
global $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

Or in the PHP in your header just use $view = views_get_current_view() and check $view->args

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 =)

Add into index.php

- this is just an example, for production sites you must find another way to add global variables :)

#5

Status:fixed» closed (fixed)

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

#6

For future reference, Merlins method in #2 does work, even with ViewReference module

nobody click here