0

I'm trying to use EE's Relationships field to select a page and get the full URI of that page.

Basically I want to be able to allow the client to select an entry from several different channels, and link directly to that entry. Maybe noteworthy - this site does not use structure or the pages module.

Here is the code I'm trying to use, where link_sbb is my Relationships field name:

{exp:channel:entries channel="sidebar_banner" limit="1" dynamic="off"}
   <a href="{link_sbb}{link_sbb:page_uri}{/link_sbb}">Learn More<span class="arrow"></span></a>
{/exp:channel:entries}

I can get url_title to work but I don't want to use path="" as the path's can be different, they can select pages from different channels/sections of the site etc. The permalink and page_url variables don't return a value either.

Is there an easy way to achieve this with EE's Relationships field?

EDIT:

Examples of possible URL's

  1. /products/category
  2. /products/category/subcategory
  3. /products/category/{url_title}
  4. /products/category/subcategory/{url_title}
  5. /applications/category
  6. /applications/category/{url_title}
  7. /resources/category
  8. /company/category
  9. /news/category
  10. /news/{url_title}
  11. /single-page
2
  • What kind of url structure are you looking to get for your link when it's output? Can you give an example? Nov 12, 2013 at 20:58
  • The url structure may be /segment_1/segment_2/segment_3/url_title or /segment_1/segment_2/url_title or /segment_1/category/url_title - they will vary from url's with categories, # of segments, etc. Nov 12, 2013 at 21:11

2 Answers 2

4

The short answer is that entries don't have URIs in EE. Content is completely separated from URL routing - it will appear wherever you decide to call it in your templates (which are essentially analogous to routing in EE). (The exception is when you set a Pages URI, or use an add-on like Structure which subverts this fundamental tenet of EE.)

So, as Siebird pointed out, you have to decide where each related entry should link based on whatever data you have at your disposal (channel, entry_id, segment variables, etc), and then construct each link directly in your template code.

3

In order for page_uri variable to work, either the pages or structure modules need to be installed. More here

Re: other options, I would either install one of the modules or you will have to have several conditions within the link_sbb tag pair to determine the correct path.

5
  • Thanks for the suggestion, I installed the pages module, but the above code still doesn't return a value. I also tested on a site with Structure installed, same result :/ Nov 12, 2013 at 20:22
  • 1
    Did you go into each entry and update the page_uri field under the 'Pages' tab?
    – Siebird
    Nov 12, 2013 at 21:20
  • No I didn't but I see now what you mean, I'm hoping there is an easier solution, this site has 100's of entries/pages - having to go into each individual entry and manually input the full URI won't be fun... Nov 12, 2013 at 21:40
  • 2
    What are all the possibilities of URL's? A conditional might be the easier route since you have 100's of entries. Update your question
    – Siebird
    Nov 12, 2013 at 22:14
  • I added the possible URL's to my question - Based on what you've said and a similar question I found - I'll try setting up a conditional with switchee... Nov 12, 2013 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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