0

I'm trying to avoid using the PHP filter due to security concerns.

I have a CCK type I already created called Slide that I am dumping out in a view. The Block dumps out all of the items with content type Slide which are then used in a homepage slider.

Within the CCK type, I have an Entity Reference field called Prog Reference that references a taxonomy value.

What I need is the URL that is associated with that Taxonomy value so I can link up the actual slide.

They click the slide -- takes them to that taxonomy term page.

Current setup:

Referenced entity: Prog Reference -- http://d.pr/i/10bX

 Entity Reference: Prog Reference 

Fields: d.pr/i/oa3z (wouldn't let me post as link)

(Taxonomy term entity referenced from field_prog_reference) Taxonomy term: Term ID
Content: Slider Image 

No Taxonomy term: Path :( -- d.pr/i/FtcC (wouldn't let me post as link)

Taxonomy term: Name
  The taxonomy term name.
Taxonomy term: Programming Image
  Appears in: taxonomy_term:programming_type.
Taxonomy term: Rendered Taxonomy term
  The Taxonomy term of the current relationship rendered using a view mode.
Taxonomy term: Term description
  The description associated with a taxonomy term.
Taxonomy term: Term edit link
  Provide a simple link to edit the term.
Taxonomy term: Term ID
  The tid of a taxonomy term.
Taxonomy term: Weight
  The term weight field

Typically you would just use the Content: Path field to get the referenced entity's path, but for some reason this isn't an option Taxonomy values?

Any ideas? All help welcome!! Appreciate in advance!

  • Drupal 7, right? Do you need this as a field on a content type or within a view result? – Jason Jan 3 '14 at 18:02
  • Oh, are you limiting the number of taxonomy terms referenced to 1? – Jason Jan 3 '14 at 18:07
  • Yeah sorry, I'll edit to add in D7. It's within a view result. Essentially I'm rewriting the slide image output to include a link to the referenced taxonomy value. Taxonomy terms are also limited to 1. Thanks! – ryanka Jan 3 '14 at 18:23
1

Ok then, here are a two options.

Option 1)

  • Include your entity reference field.
  • Use the 'Label' formatter.
  • Rewrite it's output and to /taxonomy/term/[field_entity_reference-target_id], see screenshot.

enter image description here

This will output the path to the term page as plain text for you to use as you will. You could output this field as a link and attempt the same pattern.

Option 2) + Add a relationship to the referenced entity. See screenshots. enter image description here

enter image description here

  • Once you add the relationship, add the Taxonomy term: Name field using the relationship. See screenshot.

enter image description here

<> Then configure to use link and rewrite output if desired.

enter image description here

  • Thanks a lot for your help. I knew about option 1 and 2, but neither suffice at this point. Option 1 will allow me to put in the link but I won't have the alias. Which is bad for SEO. Option 2 would require a "Read More" link under the slides and the user wouldn't be able to click the slide to take them to the page. – ryanka Jan 3 '14 at 19:17
  • I ended up just adding a field in the CCK type for the URL and having to hard-code it in. I honestly don't think Drupal supports the alias unless you write a module OR use the PHP field module (which is a huge security no-no). – ryanka Jan 3 '14 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.