6

I have a channel entry loop that is outputting entries from three different channels. Entries from each channel are marked up differently, so I have a Switchee case with the value of channel_short_name to determine which channel the entry is in and then output the appropriate markup.

{exp:switchee variable="{channel_short_name}" parse="inward"}

{case value="channel_one"}

... (Channel one markup)

{/case}

{case value="channel_two"}

... (Channel two markup)

{/case}

{case value="channel_three"}

... (Channel three markup)

{/case}

{/exp:switchee}

Within one channel, I need to have two different layouts (based on status) and cycle between classes. I'm trying to accomplish this by nesting another Switchee case using status as the value and {switch} to cycle classes.

{exp:switchee variable="{channel_short_name}" parse="inward"}

{case value="channel_one"}

... (Channel one markup)

{/case}

{case value="channel_two"}

... (Channel two markup)

{/case}

{case value="channel_three"}

   {switchee variable="{status}" parse="inward"}

   {case value="Featured"}

   <div class="channel-three featured">
      <div class="{switch="class-a|class-b}"></div>
   </div>

   {/case}

   {case default="yes"}

   <div class="channel-three not-featured">
      <div class="{switch="class-one|class-two|class-three}"></div>
   </div>

   {/case}

   {/switchee}
{/case}

{/exp:switchee}

Finally, the issue I am having is the {switch} markup nested in Switchee seems to cycle on every entry, wether the case it is wrapped in is true or not.

The output is something like this.

<div class="channel-three featured">
   <div class="class-a"></div><!-- Expecting class-a -->
</div>

<div class="channel-three not-featured">
   <div class="class-two"></div><!-- Expecting class-one -->
</div>

<div class="channel-three featured">
   <div class="class-a></div><!-- Expecting class-b -->
</div>

Is {switch} working as expected? Is there a different approach I should take on this? Any other plugins I should try?

4
  • Are you for sure running the dev branch version?
    – Natetronn
    Jan 9, 2013 at 1:33
  • Is your 2nd case actually "Featured" or "featured" I believe its case sensitive. Jan 9, 2013 at 2:19
  • @Natetronn, yes I am running the dev branch version. stuartmcd69, The 2nd case is actually "Featured". I've also tried using {switch} unnested and it also iterates when the case value is not met. Jan 9, 2013 at 16:54
  • the switch is incrementing for EACH channel:entries step. i don't think hiding it within an IF or Switchee statement does matter
    – GDmac
    Jan 13, 2013 at 14:18

1 Answer 1

1

This can probably be done on the CSS side of things also. Just set the class to something to identify the channel and use nth-child(3n+0) to style them differently.

http://www.w3schools.com/cssref/sel_nth-child.asp

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.