"like how you're meant to do stuff like switching the row color on alternate lines."
Admittedly this is a very small point in your questions, however, I already had the file open, so I thought, why not cut and paste this for you... knock off the small ones. :^)
perl:
my $bgcolor = "#d7d7d7";
for(@{$item_ref}) {
$bgcolor = ($bgcolor eq "#d7d7d7") ? "#f7f7f7" : "#d7d7d7";
push @{$nodes}, {
title => $q->escapeHTML($_->{'title'}),
text => $_->{'text'},
inid => $_->{'inid'},
timestamp => localtime( epochtime($_->{'timestamp'}) ),
bgcolor => $bgcolor,
};
}
template:
<table border="1" cellpadding="2" cellspacing="0">
<!-- snip -->
<tmpl_loop nodes>
<tr bgcolor="<tmpl_var bgcolor>">
<td align="right"><tmpl_var title></td>
<td rowspan="2"><tmpl_if inid><a href=?idisplay&img=<tmpl_var inid
+> target=_blank><img src=?getimage&img=<tmpl_var inid>&thumb border=0
+></a><tmpl_else> </tmpl_if></td>
</tr><tr bgcolor="<tmpl_var bgcolor>">
<td colspan="3">Last modified <tmpl_var timestamp> by <tmpl_va
+r user></td>
</tr><tr bgcolor="<tmpl_var bgcolor>">
<td colspan="4"><tmpl_var text></td>
</tr>
</tmpl_loop>
</table>
Possibly there is a cleaner/better way, if so I am sure I will hear about it.
ciao, -xtype
update:
Actually, you have caused me to re-evaluate that. You should keep the colours in the template or the style sheet, not in the perl!
So instead do something like this:
<tr bgcolor="<tmpl_if switch_colour>#d7d7d7<tmpl_else>#f7f7f7</tmpl_if
+>">
or
<tr id="<tmpl_if switch_colour>every<tmpl_else>other</tmpl_if>">
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.