How can I get name of Taxonomy Term in my custom View?

andymilk - October 2, 2009 - 20:46

I've created a View that filters based on an argument (Term ID). My table is filtered perfectly and that works fine.

But on the page, I'd like to display the name of the Taxonomy Term that goes along with that Term ID. How do I go about doing that?

Specifically, I'd like to display it in the views-view--[viewname].tpl.php, but I don't seem to have access to anything other than:
* - $css_name: A css-safe version of the view name.
* - $header: The view header
* - $footer: The view footer
* - $rows: The results of the view query, if any
* - $empty: The empty text to display if the view is empty
* - $pager: The pager next/prev links to display, if any
* - $exposed: Exposed widget form/info to display
* - $feed_icon: Feed icon to display, if any
* - $more: A link to view more, if any
* - $admin_links: A rendered list of administrative links
* - $admin_links_raw: A list of administrative links suitable for theme('links')

How can I query for the Taxonomy Term's names based on the Term ID argument?

Thanks,
Andy

Label

GreenSpiderDesign - October 2, 2009 - 21:13

When you select Taxonomy Term and you then go to the Configure Field Taxonomy Term page there is a field for Label that you can update to whatever you want it to be.

That doesn't really help. Let

andymilk - October 3, 2009 - 14:35

That doesn't really help.

Let me try to be more specific. Let's say I have a list of Taxonomy Terms.

- Green Cars
- Blue Cars
- Red Cars

If I click on one of those, I'm going to a Custom View, that takes the Term ID as an argument. Something like: /cars/14 (14 is the Term ID)

On that cars page, I'd like to show some header content, and the Term name at the top:

Blue Cars

---List of blue cars (custom view)

Any ideas?

I figured this one out, I

andymilk - October 3, 2009 - 17:29

I figured this one out, I used this:

$title = taxonomy_get_term(arg(1));
print $title->name;

 
 

Drupal is a registered trademark of Dries Buytaert.