• 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.

    https://www.ads-software.com/plugins/catablog/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thank you for sharing :). I can see your logic and it makes sense.

    I personally prefer to use the following shortcode options to sort the CataBlog items. This might not be the same as your code tweak above but it prevents you from having to hack the plugin core files.

    Example:

    [catablog sort=”date” order=”desc”]
    and
    [catablog category=”zynga2″ limit=”1″]

    Sort: The sort option lets you set the order your catalog items will be displayed, particularly which field they will be sorted by. This value should be one of these four values: title, date, menu_order or rand. Currently non of the other catalog item values can be used to sort, this may change in a future version.

    Order: The order option lets you set the direction your catalog items will be sorted in. There are two acceptable values for this option are asc and desc, ascending and descending respectively.

    Thread Starter Marceau

    (@marceau)

    Hi,
    yes i agree with you that some tags have the “sort” aguments in catablog.
    But unfortunatelly there is no shortcode “sort” option if you use the spécific tag [catablog_gallery id=xxx].
    ie create a blank page and add this type or shotcode: [catablog_gallery id=xxx sort=”Title”] => it doesn’t work.
    Regards.

    Hi, yes you are correct. I did some testing and sort=”title” does not work when used with the following shortcode [catablog_gallery id=xxx].

    I have been trying to contact the developer about releasing an up to date version. But I have not been successful. I hope he will get in contact soon and release an updated plugin version and include your patch.

    Thank you for spotting this and sharing with the WordPress community ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hack to sort your catablog_gallery ID (for Catablog Version 1.6.6)’ is closed to new replies.