I have a custom block showing the users whose content has attracted most pageviews.
part of my code is this:
print "<tr class=""; print $zebra; print ""><td>";
this is a drupal 6 installation and I don't seem to be able to get the odd/even classes I'm looking for. If I put print "odd", they all come out grey, "even" and they all come out white, so I know the syntax of the code is fine...I just can't get the zebra variable working.
any tips what I'm failing to do??
Neil
try this
function isEven($x){if($x%2==0){return true;}else{return false;}} $oddeven=1;
print "<tr class=""; if(isEven($oddeven){print "even";}else{print "odd";})$oddeven++ print ""><td>";
R.A.Smith Manager/Technical Lead Exterbox - "Thinking outside of the box" http://www.exterbox.com rohan@exterbox.com 1-876-449-7506
On Sat, Jun 12, 2010 at 10:06 AM, Neil Coghlan neil@esl-lounge.com wrote:
I have a custom block showing the users whose content has attracted most pageviews.
part of my code is this:
print "<tr class=""; print $zebra; print ""><td>";
this is a drupal 6 installation and I don't seem to be able to get the odd/even classes I'm looking for. If I put print "odd", they all come out grey, "even" and they all come out white, so I know the syntax of the code is fine...I just can't get the zebra variable working.
any tips what I'm failing to do??
Neil
-- [ Drupal support list | http://lists.drupal.org/ ]
try this
function isEven($x){if($x%2==0){return true;}else{return false;}} $oddeven=1;
print "<tr class=""; if(isEven($oddeven){print "even";}else{print "odd";})$oddeven++ print ""><td>";
I would say:
print "<tr class=""; print ($oddeven%2) ? "odd" : "even"; $oddeven++; print ""><td>";
:)
F
Le mercredi 16 juin 2010 à 17:32 +0300, Fred Jones a écrit :
try this
function isEven($x){if($x%2==0){return true;}else{return false;}} $oddeven=1;
print "<tr class=""; if(isEven($oddeven){print "even";}else{print "odd";})$oddeven++ print ""><td>";
I would say:
print "<tr class=""; print ($oddeven%2) ? "odd" : "even"; $oddeven++; print ""><td>";
:)
F
Or the condensed version:
print "<tr class="" . (($oddeven++ % 2) ? "odd" : "even") . ""><td>";
I like obfuscation, this is the story of my life. (If it does not work, add parenthesis around the $oddeven++).
Pierre.
open source wins :-P - (said the lead developer)
R.A.Smith Manager/Technical Lead Exterbox - "Thinking outside of the box" http://www.exterbox.com rohan@exterbox.com 1-876-449-7506
On Wed, Jun 16, 2010 at 9:46 AM, Fred Jones fredthejonester@gmail.comwrote:
Or the condensed version:
print "<tr class="" . (($oddeven++ % 2) ? "odd" : "even") . ""><td>";
I am humbled.
I like obfuscation, this is the story of my life.
Code obfuscation? +1 for job security. :)
LOL
[ Drupal support list | http://lists.drupal.org/ ]
Le mercredi 16 juin 2010 à 17:46 +0300, Fred Jones a écrit :
Or the condensed version:
print "<tr class="" . (($oddeven++ % 2) ? "odd" : "even") . ""><td>";
I am humbled.
I like obfuscation, this is the story of my life.
Code obfuscation? +1 for job security. :)
LOL
Ahah :)
I could have wrote:
list($would, $beer, $I, $love, $some) = array( (bool) (((((int)$oddeven)++) % 2) == 0), ""><td>" "<tr class="", "odd", "even" );
// WTF! print $I . ($would ? $love : $some) . $beer;
// Tell me if that works please :)
Pierre.
haha, thought this question had died, then it bursts into life few days later. I'll try these suggestions today and see if they work.
thanks everyone.
just out of interest, does the $zebra variable not work anymore in D6? Why would my original code not work?
sorry, I'm always one for not only finding out the solution, but also why a supposed alternative doesn't work.
Neil
Pierre Rineau wrote:
Le mercredi 16 juin 2010 à 17:46 +0300, Fred Jones a écrit :
Or the condensed version:
print "<tr class="" . (($oddeven++ % 2) ? "odd" : "even") .
""><td>";
I am humbled.
I like obfuscation, this is the story of my life.
Code obfuscation? +1 for job security. :)
LOL
Ahah :)
I could have wrote:
list($would, $beer, $I, $love, $some) = array( (bool) (((((int)$oddeven)++) % 2) == 0), ""><td>" "<tr class="", "odd", "even" );
// WTF! print $I . ($would ? $love : $some) . $beer;
// Tell me if that works please :)
Pierre.
-- [ Drupal support list | http://lists.drupal.org/ ]