I have an entries page where I want to show related entries from other channels using Solspace Tag's {exp:tag:related_entries} tag pair. Since they are from different channels I need to have the correct path to lead to the correct template. At the moment I have split this in to two related_entries tags, but I was wondering if there was a way of combining them in to one?

{exp:tag:related_entries url_title="{segment_3}" channel="channel_A" orderby="date" sort="desc" limit="5" paginate="bottom"} {title}{/exp:tag:related_entries}

{exp:tag:related_entries url_title="{segment_3}" channel="channel_B" orderby="date" sort="desc" limit="5" paginate="bottom"} {title}{/exp:tag:related_entries}

3 Answers 3


You said that your problem is to make the URL's point to the right template. If you don't mind about to have 10 entries from both channels, instead of 5 of every one, you can merge the variable pair and use a conditional.

{exp:tag:related_entries url_title="{segment_3}" channel="channel_A|channel_B" orderby="date" sort="desc" limit="10" paginate="bottom"}
  {if channel_short_name == "channel_A"}
    <a href="{url_title_path='channel_A_template_group/template'}">{title}</a>
  {if channel_short_name == "channel_B"}
    <a href="{url_title_path='channel_B_template_group/template'}">{title}</a>
  • That would be my initial suggestion as well. This is a similar strategy to creating different URLs based on channel_short_name in {exp:channel:entries}. An alternative is to use what was suggested in other answers here and use the {channel_url}
    – Solspace
    Commented Aug 9, 2013 at 15:37
  • This seems like a good solution for me as it also will allow me to define a channel field from which to pull a short extract. Thanks.
    – Kenny
    Commented Aug 16, 2013 at 10:16

If your template group names match the short name of your channels then simply use {channel_short_name}

So you could do:

{exp:tag:related_entries url_title="{segment_3}" channel="channel_A|channel_B"  orderby="date" sort="desc" limit="10" paginate="bottom"}
   <a href="{channel_short_name}/template'}">{title}</a>

In your channel settings you have the ability to enter a channel url and a channel comment page url - and when it is filled in, it is available to you as a variable in your entries loop (normally - whether it is within the tag module I couldn't say, but it very well may be). It has the same effect as url_title_path, for example. But instead of something like:

    <a href="{url_title_path='template_group/single_entry_template'}">{title}</a>

You instead then have the ability to use:

    <a href="{comment_url_title_auto_path}">{title}</a>

Which then allows your single entry view path to be automatically assigned based on what you have entered into the channel's preferences, therein pointing them to the right template for viewing on a channel by channel basis.

Another approach would be to use the channel short name, and then use an add-on like switchee to early parse a conditional that allows you to define the template path for the single entry view. Same idea as Robson's suggestion, just parsing the conditional with an add-on for performance, particularly if there are any other conditionals within the parent conditional needed.

    {exp:switchee variable="{channel_short_name}" parse="inward"}
        {case value="channel_short_name_A"}
            <a href="{url_title_path='channel_A_template_group/channel_A_single_entry_template}">{title}</a>
        {case value="channel_short_name_B"}
            <a href="{url_title_path='channel_B_template_group/channel_B_single_entry_template}">{title}</a>
        {case value="channel_short_name_C"}
            <a href="{url_title_path='channel_C_template_group/channel_C_single_entry_template}">{title}</a>

If you have to do this in a bunch of different places though, it may be a bit cleaner to use the channel settings option rather than do it in template like this, since you risk repeating yourself a bit. And in particular, if the comment_url_title_auto_path is not available within the tag module's loop, then this switch case method will be a way around that.

Your Answer

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

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