how to cycle row colors for every UDT instance

General project discussion. NOT for help questions.
Post Reply
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

how to cycle row colors for every UDT instance

Post 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!
Last edited by blackhawk on Thu Nov 04, 2010 9:35 pm, edited 1 time in total.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: how to cycle row colors for every UDT instance

Post 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
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: how to cycle row colors for every UDT instance

Post 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.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: how to cycle row colors for every UDT instance

Post 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
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: how to cycle row colors for every UDT instance

Post 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!
Last edited by blackhawk on Thu Nov 04, 2010 9:38 pm, edited 1 time in total.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: how to cycle row colors for every UDT instance

Post 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');
    }
);
Peciura

Re: how to cycle row colors for every UDT instance

Post by Peciura »

I use smarty for "zebra effect"
more info http://www.smarty.net/manual/en/languag ... .cycle.php
Post Reply

Return to “General Discussion”