Hi,
I'm really having trouble navigating my way through the fog of Views variable peril.

What I am trying to do is make an exposed filter out of graphics because it has to look like the design of the web company whose site I am converting.

I have my view working, and the expose filters work great but now I have to get rid of the filters and make my own.

I have figured out the that the argument for the views is in the url and I can use links in the header to call certain arguments.

The graphics I have change depending on which argument is selected.
So I figure I need to be able to access the current argument which is a term id and a cck field that holds the year.

These graphics need to show that they are selected when the page changes.

I found the get current view command but looking at the object I can't see where it holds this information.

I can't access the $node variable because it is a View that loads nodes and so it isn't there either.

I found something about the $args[0] variable but that seems to give me the path and I can't get at the details afterwards.

I am trying to access these variables from the views header with PHP.

Where could I find these variables?
Or do I have to strip the url or something?

Any help would be glorious! I'm really clueless right now.

Comments

Bensbury’s picture

I'm using the $_GET['my variable name'] in my PHP header now.
It works but just seems a poopy way of doing it.

If there is a better/proper way of doing this I would love to know it.
I don't really want to hack up Drupal because I am well aware I don't know what I'm doing and my impression is that Drupal would have somewhere clever to access this kind of data - it usually does.

Cheers,
Ben.

Bensbury’s picture

I'm just updating this in case another poor sod stumbles across the same problem.

I get it. It's all about arguments.

Filters sets up the initial group/blend you wish to view.

If you want to manipulate the view further from that point you open it up with arguments.

I'm going to study arguments now.........be back when I figured it out.

dawehner’s picture

Status: Active » Fixed

use the following code

<?php
$view = views_get_current_view();
$args = $view->args;
?>

But i'm not sure whether you can alter it here.

Status: Fixed » Closed (fixed)

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

grasmash’s picture

Example usage for creating a link using the first views argument:


$view = views_get_current_view();
$args = $view->args;
$nid = $args[0];

$link = "<a href='".base_path()."my-page/".$nid."'>My Page</a>";

echo $link;

eiland’s picture

i've been spending so much time on this to find it, ill now just subscribe to it, and add the keywords arg(0), views2, $argument and args.

glitz’s picture

I have a similar problem.

Im trying to use php in a view header but want to use the same argument I have set up in the view to display a link.

For instance I have a view with only 1 argument :User:UID.
The view works perfect (Only shows on the user profile page) but the header link shows on every page, and dosent take the User:UID argument.
(Therefore the link shows on ly every profile page but I want this link to only show on the logged in users profile page, as the view does)

Here is what Im using in the header (php input) field:

$view = views_get_current_view();
$arg0 = $view->args[0];

< a href="http://www.sitename.com/">Site name

Nothing has changed and the link still is appearing on all profile pages and does not seem to be taking the arguement (tested with views preview).

Can someone please help with ideas?

Thanks