[+phx:if=`[[getField? &docid=`5` &field=`published`]]`:is=`1`:then=`<img src="photo[[iteration]]" />`+] [+phx:if=`[[getField? &docid=`10` &field=`published`]]`:is=`1`:then=`<img src="photo[[iteration]]" />`+] [+phx:if=`[[getField? &docid=`11` &field=`published`]]`:is=`1`:then=`<img src="photo[[iteration]]" />`+]
<?php $iterator+=1; return $iterator; ?>
$counter = 0; if (some condition) $counter++; if (some condition) $counter++; if (some condition) $counter++;
<DIV id="number1">some content</div> <DIV id="number2">some content</div> <DIV id="number3">some content</div>
<?php $_SESSION['iter']=1; return $_SESSION['iter']; ?>
<?php $_SESSION['iter']++; return $_SESSION['iter']; ?>
[[init]] [[iteration]] [[iteration]] [[iteration]]
1 2 2 2
[[!iteration]]
It doesn’t work
Try:
[[!iteration]]
If you can explain exactly what you’re trying to accomplish, and why, there may be a better solution.
<ul> <li> Spec 1</li> <li class="even">Spec 2</li> <li> Spec 3</li> <li class="even">Spec 4</li> </ul>
<ul> [*phx:if=`[*Spec1*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec1*]</li>`:else=``*] [*phx:if=`[*Spec2*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec2*]</li>`:else=``*] [*phx:if=`[*Spec3*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec3*]</li>`:else=``*] [*phx:if=`[*Spec4*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec4*]</li>`:else=``*] </ul>
In revolution, there is a modulus output modifier that returns 0 or 1. It defaults to %2 so [[Iterator]]:modulus should be 0 or 1. I’m not sure if it exists in Evolution, but it’s worth a try.
The modifier in Revo can be referred to as :modulus or :mod.
<?php $_SESSION['iter']++; return $_SESSION['iter']; ?>
<ul> [*phx:if=`[*Spec1*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec1*]</li>`:else=``*] [*phx:if=`[*Spec2*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec2*]</li>`:else=``*] [*phx:if=`[*Spec3*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec3*]</li>`:else=``*] [*phx:if=`[*Spec4*]`:ne=``:then=`<li [*phx:if=`[[iterator]]%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec4*]</li>`:else=``*] </ul>
<ul> [*phx:if=`[*Spec1*]`:ne=``:then=`<li [*phx:if=`1%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec1*]</li>`:else=``*] [*phx:if=`[*Spec2*]`:ne=``:then=`<li [*phx:if=`1%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec2*]</li>`:else=``*] [*phx:if=`[*Spec3*]`:ne=``:then=`<li [*phx:if=`1%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec3*]</li>`:else=``*] [*phx:if=`[*Spec4*]`:ne=``:then=`<li [*phx:if=`1%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec4*]</li>`:else=``*] </ul>
<ul> [*phx:if=`[*Spec1*]`:ne=``:then=`<li [*phx:if=`1%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec1*]</li>`:else=``*] [*phx:if=`[*Spec2*]`:ne=``:then=`<li [*phx:if=`2%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec2*]</li>`:else=``*] [*phx:if=`[*Spec3*]`:ne=``:then=`<li [*phx:if=`3%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec3*]</li>`:else=``*] [*phx:if=`[*Spec4*]`:ne=``:then=`<li [*phx:if=`4%2`:is=`0`:then=`class="even"`:else=``*] >[*Spec4*]</li>`:else=``*] </ul>
[!Iterator? &specs=`Spec1,Spec2,spec3,Spec4`!]
<?php /*Iterator snippet */ $iterator=0; $allSpecs = explode(',', $specs); $output=''; foreach($allSpecs as $spec) { $output .= '<li'; if ($iterator%2) { $output .= ' class="even "'; } $iterator ++; $output .= '>[*' . $spec . '*]</li>' . "\n"; } return $output;