I have created a page view to show data depending on which taxonomy term id is submitted in the url. This works. While %1 in title tells me what taxonomy term requested, I can't seem to get any variables to show up in the page header field. The page header does display text and php code though when I used several variables I thought would be available, everything was empty.

I would like to create a PHP snippet that returns a different header for the page based on what term is submitted. So I want to test what term it is so I can make the choice. Is this possible in the header field or do I need to put it in my phptemplate?

Comments

merlinofchaos’s picture

Status: Active » Fixed

There are no special variables available in the header. It's surprisingly hard to get variables to it.

You can use global $current_view; to get the $view, and it's full of all kinds of interesting data that you'll need to look through to find what you want.

srcerer’s picture

I see a lot of data and I could parse the url to figure out the term id and display the appropriate data. But $current_field is empty for taxonomy terms that have nothing assigned yet. So it may not make sense to rely on putting standard, overview text in the Header field. There are other places for it but I thought this would be easy...

Thanks for the quick response!

merlinofchaos’s picture

Look in $current_view->args -- that should give you the raw arguments that came in. You have to know which argument is your tid (which is probably the only argument) -- then you can load the information from the database.

Yes, stuff like this ought to be easier. Unfortunately, for every thing Views does to make your life easier, there' sosmething else it doesn't do that it seems like it could. This is one of them. =)

Anonymous’s picture

Status: Fixed » Closed (fixed)