TextPattern: Alternating rows in backend

10
Jul

As I’m a total fan of alternating row colors that improve usability immensely, I wanted to have these in the TextPattern backend (article listing). The article listing page of TextPattern is built up using table rows (<tr>) which are predestined to be colored with alternating colors. The final HTML-output of a backend page is generated using lots of functions and libraries. But the sourcecode of TextPattern is cleaned up and well structured so it’s just a small change in one PHP-file and the general CSS-file of TextPattern.
Alternating rows in backend In order to do the change, open your TextPattern-folder (you can do it live on your FTP of course but you should backup the file before you edit it) and navigate to the path ‘textpattern/include’. There, you’ll find the file ‘txp_list.php’ which you need to edit. After opening the file in your favorite editor, go to line 195 and add the following two lines (lines 197 and 202).

194
195
196
197
198
199
200
201
202

203
204
205
...
include_once txpath.'/publish/taghandlers.php';

$tr_even_odd = "odd";

while ($a = nextRow($rs))
{

if ($tr_even_odd == "odd") { $tr_even_odd = "even"; } else { $tr_even_odd = "odd"; }

extract($a);
...
No, go to line 289 and add the following code to the line (the code you’ll have to add behind the two )) is , ' class="'.$tr_even_odd.'"').
286
287
288
289
290
291
...
? fInput('checkbox', 'selected[]', $ID)
: '&nbsp;'
)), ' class="'.$tr_even_odd.'"'
);
...
Save the file and close it. Navigate one level up to the file ‘textpattern.css’ which is located in the ‘textpattern-subdirectory’. Open it and jump to line 327. Add the following three lines of code to the file.
324
325
326
327
328
329
330
331

332
...
table#list li {
margin: 0 0 2px 0;
}

table#list tr.even {
background-color: #f8f8f8;
}
...

That’s it. Of course you can adjust the grey color ‘f8f8f8’ and add more CSS-properties.

Article postedPosted in @ 07/10/08

Comments