ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Dynamic Links

October 18, 2011 6:54am

Subscribe [3]
  • #1 / Oct 18, 2011 6:54am

    Evolve Websites

    110 posts

    Hi there,

    I’m trying to find out if there’s a way to set the template group in link paths dynamically. Let me explain:

    I’m building a site that has three main sections, which are divided using three different channels and three different template groups.

    When linking from an article, I can simply specify the template group like so:

    <a href="http://{url_title_path=/get-the-know-how/article}">
    __But when you come from a search results page (from the Solspace Tag module in this case), articles from the three different channels are displayed, but are all created from one chunk of code (see below).__The challenge is to get the links to use the relevant template groups.__Any ideas are appreciated!__
    {exp:tag:entries inclusive="yes" orderby="entry_date" sort="asc" limit="20" paginate="bottom"}_      <div class="full-story">_       <div class="full-thumbnail">_        {if image_square_thumbnail != ""}_         <a href="{url_title_path='/get-the-know-how/article'}">_          {exp:ce_img:single src="{image_square_thumbnail}" width="150" height="150" crop="yes"}_         </a>
            {if:else}
             <a href="http://{url_title_path=/get-the-know-how/article}">_          {exp:ce_img:single src="{image_large_image}" width="150" height="150" crop="yes"}_         </a>
            {/if}
           </div>
           <div class="full-info">
            <h2><a href="http://{url_title_path=/get-the-know-how/article}">{exp:low_widont}{title}{/exp:low_widont}</a></h2>
    <p>        Date: {entry_date format="%d/%m/%y"}  |  Author: <span class="orange">{author}</span></p>
    
    <p>         Tags: <span class="orange"><br />
              {exp:tag:tags<br />
                 entry_id="{entry_id}"<br />
                 backspace="2"<br />
                 orderby="tag_name"<br />
                 sort="desc"}<br />
                 <a href="http://{path=}tag/{websafe_tag}">{tag}</a>,{/exp:tag:tags}</span><br />
            {exp:low_widont}{introduction}{/exp:low_widont}<br />
            <a href="http://{url_title_path=/get-the-know-how/article}class=read-more">Read more</a><br />
           </div><br />
          </div><br />
         {/exp:tag:entries}

    Moved to Community Help forum by Moderator

     

  • #2 / Oct 18, 2011 8:08am

    Steve Abraham

    149 posts

    Hi Tom,

    Do your channel short names match the template group names, i.e. “get-the-know-how”?

    If so, you could use {channel_short_name} to construct your links.

    Just an idea.

    Cheers,
    S.

  • #3 / Oct 18, 2011 8:49am

    Sue Crocker

    26054 posts

    Hi, Tom. Since you’re asking about a third party add-on, I’m going to move this to the Community Help forum for additional community support.

    Thanks for the assist, Steve!

  • #4 / Oct 18, 2011 9:30am

    Evolve Websites

    110 posts

    Thanks Steve, brilliant suggestion.

    My template groups and channels now match, but I’m getting an error from the link.

    Code is as follows:

    {url_title_path="/{channel_short_name}/article”}

    Am I using the wrong path type (i.e. url_title_path or path etc.)?

  • #5 / Oct 18, 2011 9:34am

    Steve Abraham

    149 posts

    Hi Tom,

    It might be worth building your links manually, rather than using url_title_path, see if that sorts the issue first, i.e.:

    <a href="/{channel_short_name}/{url_title}">

    Cheers,
    Steve.

  • #6 / Oct 18, 2011 11:07am

    Evolve Websites

    110 posts

    Worked a treat, thanks Steve.

    Do you know what url_title_path does? I don’t understand why you wouldn’t just build links the way you have above as they’re still dynamic surely?

  • #7 / Oct 18, 2011 11:21am

    Steve Abraham

    149 posts

    Generally I do always tend to manually build links, but it very much depends on each person’s situation and how you build your templates.

    One thing to keep in mind is that with the automatic links, should you decide to change index.php (hide it, change it’s name) or other similar changes, the path= or url_title_path= will update automatically. With your manual links you’ll need to change them yourself. Not a common occurrence in most cases though I suspect.

    Glad you got sorted though.
    Cheers,
    Steve.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases