[Done]: Enhanced Breadcrumbs in Meta Albums [Done]: Enhanced Breadcrumbs in Meta Albums
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Done]: Enhanced Breadcrumbs in Meta Albums

Started by jesusarmy, January 10, 2008, 05:37:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jesusarmy

Breadcrumbs in CPG's meta-albums (last additions, last comments, most viewed, search etc) can be misleading in image display mode. The breadcrumb trail displayed is the normal route to the picture, not the one via the meta album, while the navigation buttons (thumbnail view, next, previous) and title bar use the meta album.

These changes correct that behaviour to the one that I feel is more intuitive, so that the breadcrumb trail shares the same behaviour as the navigation buttons and title bar.

See below for the code

jesusarmy

#1
Breadcrumbs in CPG's meta-albums (last additions, last comments, most viewed, search etc) can be misleading in image display mode. The breadcrumb trail displayed is the normal route to the picture, not the one via the meta album, while the navigation buttons (thumbnail view, next, previous) and title bar use the meta album.

These changes correct that behaviour to the one that I feel is more intuitive, so that the breadcrumb trail shares the same behaviour as the navigation buttons and title bar.

In include/functions.inc.php, find:

function breadcrumb($cat, &$breadcrumb, &$BREADCRUMB_TEXT)
{
        global $album, $lang_errors, $lang_list_categories;

and change to:
function breadcrumb($cat, &$breadcrumb, &$BREADCRUMB_TEXT)
{
        global $album, $lang_errors, $lang_list_categories,$lang_meta_album_names;


a line or two later, after:
          global $CONFIG,$CURRENT_ALBUM_DATA, $CURRENT_CAT_NAME;

add
         if ($_GET['uid'] != 0) {
           $user_name = get_username($_GET['uid']);
           if (!$user_name) $user_name = 'Mr. X';
           $lang_meta_album_names['lastupby'] = $lang_meta_album_names['lastup']." (" . $user_name . ")";
           $lang_meta_album_names['lastcomby'] = $lang_meta_album_names['lastcom']." (" . $user_name . ")";
          }


then find a few lines lower down:

        foreach ($category_array as $category)
        {
            $breadcrumb_links[$cat_order] = "<a href=\"index.php?cat={$category[0]}\">{$category[1]}</a>";
            $BREADCRUMB_TEXTS[$cat_order] = $category[1];
            $cat_order += 1;
        }

        //Add Link for album if aid is set
        if (isset($CURRENT_ALBUM_DATA['aid']))
        {
            $breadcrumb_links[$cat_order] = "<a href=\"thumbnails.php?album=".$CURRENT_ALBUM_DATA['aid']."\">".$CURRENT_ALBUM_DATA['title']."</a>";
            $BREADCRUMB_TEXTS[$cat_order] = $CURRENT_ALBUM_DATA['title'];
        }


and change to:

        foreach ($category_array as $category)
        {
            $breadcrumb_links[$cat_order] = "<a href=\"index.php?cat={$category[0]}\">{$category[1]}</a>";
            $BREADCRUMB_TEXTS[$cat_order] = $category[1];
            $cat_order += 1;
            $cat_link = $category[0];
        }

        //Add Link for album if aid is set
        if (isset($CURRENT_ALBUM_DATA['aid']))
        {
            $breadcrumb_links[$cat_order] = "<a href=\"thumbnails.php?album=".$CURRENT_ALBUM_DATA['aid']."\">".$CURRENT_ALBUM_DATA['title']."</a>";
            $BREADCRUMB_TEXTS[$cat_order] = $CURRENT_ALBUM_DATA['title'];
            $cat_link = -$CURRENT_ALBUM_DATA['aid'];
        }

        //Add Meta album link
        if (isset($album) && !is_numeric($album)) {
          if (isset($_GET['cat']) && $_GET['cat'] < 0) $cat_order += 1; //Does meta album link overwrite album?
          $set_uid = isset($_GET['uid']) ? "&amp;uid=".$_GET['uid'] : '';
          if ($cat != 0) {
            $breadcrumb_links[$cat_order] = "<a href=\"thumbnails.php?album=".$album."&cat={$cat_link}".$set_uid."\">".$lang_meta_album_names[$album]."</a>";
          } else {
            $breadcrumb_links[$cat_order] = "<a href=\"thumbnails.php?album=".$album.$set_uid."\">".$lang_meta_album_names[$album]."</a>";
          }
          $BREADCRUMB_TEXTS[$cat_order] = $lang_meta_album_names[$album];
        }


In thumbnails.php

find:
} elseif (isset($cat) && $cat) { // Meta albums, we need to restrict the albums to the current category

change to:
} elseif (isset($cat) && $cat && $album !="lastupby" && $album != "lastcomby") { // Meta albums, we need to restrict the albums to the current category
// except lastupby and lastcomby as CPG currently restricts these to the user's albums


In displayimage.php, find:
$album = isset($_GET['album']) ? $_GET['album'] : '';
after add:
$cat = isset($_GET['uid']) && ($album == "lastupby" || $album == "lastcomby") ? 0 : $cat;
// Lastupby and lastcomby meta albums need category restriction removed as CPG currently restricts to the user's albums


and find:

    } else {
        $actual_cat = $CURRENT_ALBUM_DATA['category'];
        breadcrumb($actual_cat, $breadcrumb, $breadcrumb_text);
    }

and change to:

    } else {
        $actual_cat = $CURRENT_ALBUM_DATA['category'];
        if ($cat < 0) {
          breadcrumb($actual_cat, $breadcrumb, $breadcrumb_text);//breadcrumbs for meta albums in categories
        } else {
          breadcrumb($cat, $breadcrumb, $breadcrumb_text);//breadcrumbs for meta albums in albums
      }
    }



I'm sure this could be improved but I hope someone else finds this useful. :-)


Joachim Müller

Thanks for sharing. Moving to bugs board to make sure this suggestion is not going to be forgotten.

Paver

Nice work.  Committed to 1.5. 

This is not really a bug but a poorly-designed feature of 1.4, so maybe this thread should be moved to "Feature Requests" and marked "Done" for future reference?

Joachim Müller