Page 1 of 1

how to cycle row colors for every UDT instance

Posted: Wed Nov 03, 2010 6:40 am
by blackhawk
I have multiple statements communicating with the same UDT in one of my content pages like this...

Code: Select all

{myudt name="larry" color="red" item="shoe"}
{myudt name="joe" color="blue" item="tshirt"}
{myudt name="mike" color="green" item="hat"}
{myudt name="fred" color="orange" item="pants"}
the {myudt} in the UDT looks something like...
print '$name$color$item';

With this setup, is there a way to cycle background colors on the that is being loaded from the UDT?  (like the smarty cycle feature which changes colors on the content page? I just want to style {myudt...} every time, and for each time i do that, see a different background color, thats all.


Thanks for any tips!

Re: how to cycle row colors for every UDT instance

Posted: Wed Nov 03, 2010 6:42 pm
by Nullig
You could pass all the names in one call to the UDT, then use the cycle within it.

{myudt names="larry,joe,mike,fred"}

In the UDT convert the $names to an array and cycle your output on them.

Nullig

Re: how to cycle row colors for every UDT instance

Posted: Wed Nov 03, 2010 7:22 pm
by blackhawk
yes you are right in a creative solution, but its for a client's usability who plans on adding {myudt...}, modifying them, editing them, etc.. it's gonna be a lot of them too.

Re: how to cycle row colors for every UDT instance

Posted: Thu Nov 04, 2010 12:34 am
by Nullig
Use one of the Extra fields and have the client add the names to it (comma separated), then capture the content of that field and pass it to your udt.

Nullig

Re: how to cycle row colors for every UDT instance

Posted: Thu Nov 04, 2010 9:31 pm
by blackhawk
That is a cool idea!  Thanks for helping build another technique even though its not exactly what I'm looking for at the given moment. The client wants to 'see' all values at one time in tabular form, this way he can match what he see's on the front end of the web page which is displayed in tabular form.  I'll figure something out.  

But thank you!

Re: how to cycle row colors for every UDT instance

Posted: Mon Nov 08, 2010 12:41 am
by blackhawk
I was able to continue my UDT tag layout as I originally explained above and simply added jquery to the page to alternate the tr row background colors!

Code: Select all

$( function()
    {
        $('table tr:even').addClass('even');
        $('table tr:odd').addClass('odd');
    }
);

Re: how to cycle row colors for every UDT instance

Posted: Tue Nov 09, 2010 2:40 am
by Peciura
I use smarty for "zebra effect"
more info http://www.smarty.net/manual/en/languag ... .cycle.php