Hack to sort your catablog_gallery ID (for Catablog Version 1.6.6)
-
It may interest someone so i put it there.
By default when you use a shortcode like this in a page : [catablog_gallery id=”123″ template=”yourfavoritetemplate”] , the items aren’t sorted so they appear in the order you created them in the back office.
In this case there is no way to use a “sort=whatever” parameter.
Here’s a hack to sort your items by title :
Go to wp-content\plugins\catablog\lib
Open Catablog.class.php
Go to line 2466, you should have :ob_start();
if ($navigation) {
if ($this->options[‘nav-location’] != ‘bottom’) {
$this->frontend_build_navigation($paged, $limit, $total);
}
}echo “<div class=’catablog-catalog’>” ;
foreach ($gallery_item_ids as $item_id) {
echo $this->frontend_render_catalog_row($gallery_items[$item_id], $template);
}echo “</div>”;
replace like that :
ob_start();
if ($navigation) {
if ($this->options[‘nav-location’] != ‘bottom’) {
$this->frontend_build_navigation($paged, $limit, $total);
}
}
// Modify from here and add :function cmp_gallery_item($a, $b) {
return strcmp($a->getTitle(), $b->getTitle());
}usort($gallery_items, “cmp_gallery_item”);
echo “<div class=’catablog-catalog’>” ;
// REM REMOVED to sort the catalog
// foreach ($gallery_item_ids as $item_id) {
// echo $this->frontend_render_catalog_row($gallery_items[$item_id], $template);foreach ($gallery_items as $item) {
echo $this->frontend_render_catalog_row($item, $template);
}
// end of modification
echo “</div>”;Enjoy !
Changing the source code of a plugin is ugly but the author doesn’t seem to update it anymore.
- The topic ‘Hack to sort your catablog_gallery ID (for Catablog Version 1.6.6)’ is closed to new replies.