Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
I've got an alternating design on my site that is driven from a clonable template... after the content the design then finishes with a unique design element, but the element's style depends if there were an odd or even number of items in the alternating list.

What's the best way to display the correct style at the end?

eg.

From clonable template's user created items:

LEFT
RIGHT
LEFT
RIGHT

From site design, we must now follow with

LEFT

But if the user adds a new item we get

LEFT
RIGHT
LEFT
RIGHT
LEFT

And so the site now needs to append

RIGHT



TY!!!
Answered my own question - let me know if there's a better way, here's how I did it...

Code: Select all
<cms:set isodd='0' 'global'/>

<cms:pages masterpage='sitetemplate-timeline.php' orderby='weight' order='asc'>

<li class='<cms:zebra '' 'timeline-inverted' />'>
    <!-- stuff -->
</li>

<cms:if isodd=='1'>
    <cms:set isodd='0' 'global' />
<cms:else /> 
    <cms:set isodd='1' 'global' />
</cms:if>

</cms:pages>
             
<cms:if isodd=='1'>
    <li class="timeline-inverted">
<cms:else />
    <li>
</cms:if>
    <!-- more stuff -->
</li>
I suggest a version with slight reduction in amount of code:

Code: Select all
<cms:pages masterpage='sitetemplate-timeline.php' orderby='weight' order='asc' >

    <li class="<cms:zebra '' 'timeline-inverted' />">
        <!-- stuff -->
    </li>

    <cms:if k_paginated_bottom >
        <cms:set li_zebra = "<cms:if "<cms:mod k_total_records_on_page '2' />" >timeline-inverted</cms:if>" scope='global' />
    </cms:if>

</cms:pages>

<li class="<cms:show li_zebra />">
    <!-- stuff -->
</li>


Perhaps, you'll find it more readable..
If interested, flag 'odd' can be set by various ways - one is from my sample -
Code: Select all
<cms:set is_odd = "<cms:mod k_total_records_on_page '2' />" />


Another one is also an improvement over my sample and is, perhaps, simplest -
Code: Select all
<cms:pages masterpage='sitetemplate-timeline.php' orderby='weight' order='asc' >

    <li class="<cms:zebra '' 'timeline-inverted' />">
        <!-- stuff -->
    </li>

    <cms:set is_odd = "<cms:zebra '1' '0' />" scope='global' />

</cms:pages>

<li class="<cms:if is_odd >timeline-inverted</cms:if>">
    <!-- stuff -->
</li>
Nice. TY!
5 posts Page 1 of 1
cron