I am using views to create a list of the different term names in a vocabulary, but i don't want them to link to their taxonomy, but to another page.

How do i do this, i have this code at the moment (i'm sure $term->name is wrong).

print $term->name "> print $term->name

I have the term selected as a field but when i do

print var_export($data, TRUE);

it comes back as NULL.

Comments

chris_huh’s picture

Drupal did some weird stuff with the code there, so here it is again:

<a href="<?php print $term->title ?>"><?php print $term->title ?></a>

casey’s picture

Which customfield are you using? "PHP Field" or "Markup"?

I was able to get this to work with a view (type: Term):

2 fields:
- Taxonomy: Term (set "exclude from display")
- Customfield: PHP Code
with value:

<a href="mycustomlinktoterm/<?php print $data->tid ?>"><?php print $data->term_data_name ?></a>
casey’s picture

Status: Active » Fixed
chris_huh’s picture

Ah yes, now i feel stupid. I was using markup, not realising there was a php one. Thanks.

Now the only problem is that is generates the term name fine but the argument that extracts that term name in another view doesn't recognise it as it expects spaces to be dashes.

What would the php code be to convert spaces into dashes in the url?

Status: Fixed » Closed (fixed)

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