Hi all,
I’m having real trouble setting up some specific link urls in a template. I’ll try to explain how I need things to work and then what the code looks like with simplified examples.
1. Requirements
Entries are stored in 2 Channels: Publications (channel_short_name=“publications”) and Guidance Management and Advice (channel_short_name=“guidance-management-and-advice”)
There are 2 corresponding Template Groups: publications and guidance-management-and-advice
The client wants to be able to display teasers for specific entries of their choice on the Publications section index page (i.e. on http://clients-domain-name.org.uk/publications). The entries could be from either channel, Publications or Guidance Management and Advice and links in the teasers should point to the correct Template Group for the entry, either publications or guidance-management-and-advice.
I’m using a Category Group and Catgeories to allow the client to select which entries appear as teasers, for example Display on Main Section Page: Publications is category 61
2. Current Template Code (simplified
{if embed:content_preview == "yes"}
{exp:channel:entries channel="publications|guidance-management-and-advice" status="not closed" category="61" disable="category_fields|member_data|pagination" dynamic="no"}
<div class="preview-pane{switch="|| preview-pane-last"}">
<h2>
<a href="http://{site_url}{channel_short_name}/{if">{title}</a>
</h2>
<p> <div class="preview-container"><br />
{exp:eehive_hacksaw words="25" append="..." allow="<h3>|<p>"}{gallery-content}{standard_body_content}{/exp:eehive_hacksaw}<br />
</div><br />
<br />
<a href="http://{site_url}{channel_short_name}/{if">Go to page</a><br />
<br />
</div><br />
{/exp:channel:entries}<br />
<br />
{/if}
3. The problem
The {channel_short_name} variable is causing the problem in the urls. I need the urls for links to entries in the Publications channel to be generated as http://clients-domain-name.org.uk/publications/entry-url-title and entries in the Guidance Management and Advice channel to generated as http://clients-domain-name.org.uk/guidance-management-and-advice/entry-url-title so that the correct template group is used.
I found out that {channel_short_name} display the channel short name of the current entry (i.e. Publications) which explains why all links are to http://clients-domain-name.org.uk/publications/entry-url-title. I need to use an equivalent variable which shows the Channel Short Name of each individual entry which is displayed as a teaser.
Really grateful for any and all help with this!
Thanks
Martin
P.S. Moderators, if you feel this is better asked in the Community Help forum please move the post.