1 (edited by 2009-02-26 16:41:21)

Topic: [HACK] Alternating templates

Name: Alternating templates
Author:
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Use different css styles for odd and even articles. A long time ago this has been discussed. No it has made it's way to the FAQ/HACK forum
Requirements: CSS knowledge
Instructions:
in shows.inc.php find

$output = $template_active;


add below

$output = str_replace("{alternating}", $showed%2, $output);


$showed%2 is a mathematical function. in this case the result can be 0 or 1. You may replace the 2 with a 3 if you wish to alternate between 3 themes. In accordance the results of the math will be 0, 1 or 2. Read more...
And this is all you need to change to the CuteNews code.

Now you can use the tag in the templates like

<div name="mycss{alternating}">


So when displaying the articles on your site the code for the first article will be

<div name="mycss0">


for the second

<div name="mycss1">


and for the third

<div name="mycss0">

So all that is left is to write your css codes.
Do note that css does NOT belong in the templates.