I have a view that has a Header with something like

This content relates to "PERSON" etc.

"PERSON" is one of the "Fields" which is used in the view, and the view uses an argument which effectively selects content for that "PERSON"

Is there a way to include "PERSON" in the header. I tried using php echo of the field info provided for the template (in the same way i would use it in a tpl), without success.

So either I am doing it wrong, or as I suspect the view first makes the header , then does the content filter/field/args/sort and then the footer, so effectively the data is unavailable.

Guidance appreciated

Comments

merlinofchaos’s picture

Status: Active » Fixed

Because it's just using the basic filters Drupal gives you, the data is not available as though it were in a template.

You can use $view = views_get_current_view() to get that data, then examine $view->arguments() -- and you probably then have to do a user_load to get the user name as well.

Anonymous’s picture

Thanks Merlin, took a day, but I finally got something to work, so have posted it here in case it may help others with limited coding skills like myself. :)

First a disclaimer - I am no expert, not even an amateur, so use at your own risk :)

This is what I finally used to add the name of a taxonomy term to the header, similar could probably used in the footer and empty text

<?php
$view = views_get_current_view();

foreach ((array)$view->args as $tid) {

  $terms = taxonomy_get_term($tid);

  foreach ((array) $terms->name as $name ) {
  echo"$name";
  }
}
?> 

Status: Fixed » Closed (fixed)

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