1

In this template I display information about characters from a TV show. This includes a season-by-season summary of significant events for a character. I am trying to work out a way where adding each new season is more streamlined. Each character is tagged for each season it appears in, with S1, S2, etc. This is what I've currently got:

{exp:tag:tags entry_id="{entry_id}"}

{if tag == "S1" OR tag == "S2" OR tag == "S3"}
{if segment_4 == ""}

<h3>Spoilers</h3>

<ul>
{if tag == "S1"}<li><a href="{comment_url_title_auto_path}/Season_One/">Season One</a></li>{/if}
{if tag == "S2"}<li><a href="{comment_url_title_auto_path}/Season_Two/">Season Two</a></li>{/if}
{if tag == "S3"}<li><a href="{comment_url_title_auto_path}/Season_Three/">Season Three</a></li>{/if}
</ul>

{/if}

{if segment_4 == "Season_One" OR segment_4 == "Season_Two" OR segment_4 == "Season_Three"}

<h3>Spoilers</h3>

{if tag == "S1"}
<h4>Season One</h4>

{{current_channel_id}_season_one}
{/if}

{if tag == "S2"}
<h4>Season Two</h4>

{{current_channel_id}_season_two}
{/if}

{if tag == "S3"}
<h4>Season Three</h4>

{{current_channel_id}_season_three}
{/if}

{/if}

{/if}
{/exp:tag:tags}

At the moment, the default entry page for a character ends up looking like this:

Spoilers

    Season One

Spoilers

    Season Two

Spoilers

    Season Three

I am not sure why the "Spoilers" heading gets repeated for each link.

Additionally, if I click through on the "Season One" link it ends up displaying season one, season two and season three in one go.

Any suggestions for how I'd need to tweak this template to get the desired result and, preferably, a setup with less duplication of tags needed each time another season is added?

1

Wow that's a lot of conditionals. This loop runs for every tag. So in this case 3 times. If you only want Spoilers to display once, try {if count == '1'}Spoilers</if} Here: {if tag == "S1"}<li><a href="{comment_url_title_auto_path}/Season_One/">Season One</a></li>{/if}

you could try

<li><a href="{comment_url_title_auto_path}/{websafe_tag}/">{tag}</a></li>{/if}

changing the tags to Season 1, Season 2 etc instead of s1, s2. Then things will be dynamic as seasons are added as well.

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.