Hi,
I m struggling to do something certainly simple with Display Suite.

I have created in a content type, a list of term (banana, peach...) from a vocabulary taxonomy called "fruit".
In Display Suite, I have created a "code field" using the token [node:field_fruit]. The result of it, is that the term "banana" (or peach) is correctly displayed on my node.

I tried to put a link on the token [node:field_fruit] using <a href="[node:field_fruit]">[node:field_fruit]</a>. The result of it is www.mysite.com/content/banana
The problem is that I m trying to the get the URL : "www.mysite.com/fruit/banana" in order to display all the node that refer to the term banana.

How can I do this ?

Comments

luketsimmons’s picture

Hi filnug,

I was just looking for the same thing, and managed to get it set up but it kind of depends on the output you want afterwards?

Basically, you have to -

Code field

  • First create the field output you want to use (or edit the one you have already created), go to Structure > Display Suite > Fields > Add a code field.
  • Give the field a label.
  • Select the entity type the field will be made available for, select Taxonomy term.
  • Where you have your code <a href="[node:field_fruit]">[node:field_fruit]</a> replace the node field tokens with taxonomy ones, i.e. <a href="[term:url]">[term:name]</a>
  • Select an input format that will provide the cleanest version of the output, i.e. Filtered or Full HTML but with no news lines added.
  • Ensure you have ticked the "this field uses tokens" checkbox.
  • Save the custom field.
  • Now set up a new view mode for the taxonomy term, go to Structure > Display Suite > View modes > Add a view mode.
  • Give it a name, like [content type] page or something like that, select Taxonomy Term under the entity type that it is available for.

Set the code field for the taxonomy output

  • Now head over to the vocabulary display, go to Structure > Taxonomy > [vocabulary] > Manage Display.
  • Under the Default view you should see Custom display settings, tick the new one you created and Save.
  • Set layout to one column (minimal amount of DS wrap-age)
  • You will see the fields available for the display, which should include the code field you created.
  • Put that into the content region for the display.
  • Set the field display to full reset (or if you want to add a wrapper go ahead).
  • Save the view mode display.

Set format for your taxonomy field

  • Finally... go to the content type display now, via Structure > [content type] > Manage Display.
  • If you have a view mode already set up to use the taxonomy field then in the Format drop down choose the View Mode : [name-of-view-mode].
  • Save the view mode.
  • The output for the field should now display the output of code field but using the taxonomy values for the token substitutions.

This will get you the output for the taxonomy term how you defined it in your post, but it does mean you will have one div wrapper from DS for the one column layout. Ideally you could add a custom layout that doesn't use any extra formatting so that you get a nice clean output for the taxonomy field.

If you aren't fussed about an extra div then this should work for you.

The alternative is if the taxonomy term field when referenced via a node token had all the extra attributes available, ie pathauto alias, path, etc. But from hunts around the web and drupal.org that appears to not be available yet.

Let me know how you get on.
thanks,
luke

swentel’s picture

Status: Active » Fixed

Waauw, great steps, thanks!

filnug’s picture

I didnt had time to test it, but I have to admit that the answer look pretty complete. Thanks @uketsimmons for taking time to write this feedback!!!

Status: Fixed » Closed (fixed)

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

jive01’s picture

not sure the above solution would consider this issue fixed. It's kind of a hackish round about way to do things. Would be more ideal if there is simply a url token made available..

kopeboy’s picture

Title: Create a URL to a term with token » Create a URL to a term with token and translate it
Issue summary: View changes
Status: Closed (fixed) » Active

What if I want to output some text together with the link and translate it?

Something like "Search for businesses in this category" below a node of type article,
where businesses is another content type that uses the same taxonomy vocabulary, category is the term in question, linked to the page showing business of that category.

Will I be able to translate the displayed field?

aspilicious’s picture

Status: Active » Closed (fixed)

As you can see, I don't have the resources to answer support requests.
Closing now, please drupal.stackexchange.com for support questions.