On my Articles page, I have a list of archived months which is growing rather large. I thought I would shorten it up by 50% by having every other one float left or right on the same line. This would work but I need to programatically set the style with php. This code doesn't work: it makes every div float:left. Why doesn't the if() statement see the value set in $style?
First time through, the condition should be false, then alternate each time it's evaluated so I get a left, right, left, right....
- Code: Select all
<cms:archives masterpage='articles.php' >
<cms:php>
if ($style == 'float:left;clear:both') {
$style = 'float:right;';
} else {
$style = 'float:left;clear:both';
}
echo '<div style="'.$style.'"><a href="<cms:show k_archive_link />"><cms:date k_archive_date format='F Y' /></a></div>';
</cms:php>
</cms:archives >
First time through, the condition should be false, then alternate each time it's evaluated so I get a left, right, left, right....