Textpattern Hack – Admin Panel Image Sorting

Nov 08 2005

Yay for being able to sort!

The directions below apply only for Textpattern 4.01/4.02 However, it wouldn’t be difficult to apply the changes to previous versions and hopefully newer ones */me prays*

  • After global $txpcfg,$extensions,$img_dir; around line 33 add the following:


// From Manfre's Mod File
$sort = gps('sort');
$dir = gps('dir');
$sort = ($sort) ? $sort : 'id';
$dir = ($dir) ? $dir : 'asc';

if ($dir == "asc") { $dir = "desc"; } else { $dir = "asc"; }
// End

  • Find, around line 58, the following code, and either delete it or comment it out:


hCell(ucfirst(gTxt('name'))) .
hCell(gTxt('image_category')) .
hCell(gTxt('tags')) .
hCell(gTxt('author')) .
hCell(gTxt('thumbnail')) .
hCell()

  • In the place of the aforementioned code, place the following:


column_head('Id','id','image',1,$dir).
column_head('Name','name','image',1,$dir).

column_head('image_category','category','image',1,$dir).
td(gTxt('tags')).
column_head('Author','author','image',1,$dir).
hCell(gTxt('thumbnail')).
hCell()

  • Find, around line 83

$rs = safe_rows_start("*", "txp_image", "1 order by category,name limit $offset,$limit");

  • Replace the aforementioned code with:

$rs = safe_rows_start("*", "txp_image", "1 order by $sort $dir limit $offset,$limit");

  • Find, around line 105, the following code:

td($elink).td($category).td($txtilelink.' / '.$txplink.' / '.$xhtmlink).

  • In front of td($elink) add the following:

td($id). Please notice the ’.’

Alternatively, depending on your textpattern installation you could download the following files, renaming the one that corresponds to your install as txp_image.php and uploading to yourtxpinstall/include/

3 responses so far

  1. This is a wonderful Modification! We have been dieing for this!

  2. Thanks! Good and simple mod. Works OOTB fine !

    But it does not exactly fit my needs, I’ld like a browsing by category, as I use categories like if they where album names… So your mod is a kind of an introduction to mods I’m gonna do to have this functionality… If I have time and if I find a remedy to laziness (or lazyness, scuse, cause I’m french).

    Whatever, thanks and good luck for your future career !

    B.Polleri – Montreal – Canada.

  3. thanks this is exactly what I was looking for.

Leave a Reply