Output breadcrumb in CUSTOM_HEADER Output breadcrumb in CUSTOM_HEADER
 

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

Output breadcrumb in CUSTOM_HEADER

Started by wwwill, June 12, 2006, 11:29:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wwwill

I want to output the {BREADCRUMB} in my {CUSTOM_HEADER} section. How do I do that? I tried looking through the forum and stopped after page 5.

I'm pretty good at PHP. It just seems it tough to track everything down.

The page can be viewed here:
http://www.nakedsoulchicago.com/sights_sounds/gallery/index.php

I would like to match the page example here:
http://www.nakedsoulchicago.com/sights_sounds/gameroom/

I need output the breadcrumb before {LANGUAGE_SELECT_LIST} and {TITLE}

My code is below. WHat's my best option.
<div class="breadcrumb">
  {CUSTOM_HEADER}
</div>
<h2 class="dk_blue1">{TITLE}</h2>
<img src="/images/pxl_dk_blue1.gif" width="575" height="2" border="0" alt="" class="rule" />
              {ADMIN_MENU}
{LANGUAGE_SELECT_LIST}
<br/>
              {GALLERY}

  {CUSTOM_FOOTER}

Paver

I see your PHP skills, and raise you one PHP theme customization . . .

Add the mod block just before the last line:
    echo template_eval($template_header, $template_vars);
in function pageheader in themes/yourtheme/theme.php (copying the function from the sample theme if your theme doesn't have it already):
    // MOD - add {HEADER_BREADCRUMB} processing to pageheader
    global $template_breadcrumb, $CURRENT_ALBUM_DATA, $cat;
    $breadcrumb = '';
    $breadcrumb_text = '';
    $breadcrumb_output = '';
    $actual_cat = (is_numeric($CURRENT_ALBUM_DATA['category']) ? $CURRENT_ALBUM_DATA['category'] : $cat);
    breadcrumb($actual_cat, $breadcrumb, $breadcrumb_text);
    if ($breadcrumb) {
        $template_breadcrumb_save = $template_breadcrumb;
        $template = template_extract_block($template_breadcrumb, 'breadcrumb');
        $params = array(
            '{BREADCRUMB}' => $breadcrumb,
        );
        $breadcrumb_output = template_eval($template, $params);
        $template_breadcrumb = $template_breadcrumb_save;
    }
    $template_vars['{HEADER_BREADCRUMB}'] = $breadcrumb_output;
    // MOD - end


Then add the tag {HEADER_BREADCRUMB} in themes/yourtheme/template.html, in the header portion (anything before the {GALLERY} tag).

wwwill

AWESOME
That worked. Now can I be even more of a pain and ask is there a way to have the last item in the breadcrumb bold, on the index and thumbnail pages like the line below the Language Select list in the example here:

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.nakedsoulchicago.com%2Fsights_sounds%2Fgallery%2Fimages%2Fgallery_screenshot.gif&hash=561eb9d5ad5f59731343aefbb5b19ee0c2b13ccb)

(I modified the index page already so it's not live, thus the screen shot)

I achieved that with code in index.php


                    case 'breadcrumb':
                        // Added breadcrumb as a separate listable block from config
                        if (($breadcrumb != '' || count($cat_data) > 0) && $cat != 0) theme_display_breadcrumb($breadcrumb, $cat_data);
                        else echo "<a href=\"/home.php\">Home</a> &gt;\n<a href=\"/sights_sounds/\">Sights &amp; Sounds</a> &gt;\n<a name=\"/sights_sounds/gallery/\" style=\"font-weight: bold; color: #000;\">Gallery</a>\n";
                        break;



Thanks for the help. Always appreciated.

Paver

I'm not sure exactly what you want.  In any case, you need to customize the breadcrumb, so you need to create a function theme_breadcrumb() in yourtheme/theme.php.

Here's one that will make the last item bold:
function theme_breadcrumb($breadcrumb_links, $BREADCRUMB_TEXTS, &$breadcrumb, &$BREADCRUMB_TEXT)
{
    global $CURRENT_PIC_DATA;

    $breadcrumb = '';
    $BREADCRUMB_TEXT = '';
    $breadcrumb_last = array_pop($breadcrumb_links);
    foreach ($breadcrumb_links as $breadcrumb_link)
    {
        $breadcrumb .= ' > ' . $breadcrumb_link;
    }
    $breadcrumb .= ' > ' . '<span style="font-weight: bold;">' . $breadcrumb_last . '</span>';
    foreach ($BREADCRUMB_TEXTS as $BREADCRUMB_TEXT_elt)
    {
        $BREADCRUMB_TEXT .= ' > ' . $BREADCRUMB_TEXT_elt;
    }

/*
    // Add filename to breadcrumb (if displayimage.php of course)
    if ($CURRENT_PIC_DATA['filename']) {
        // Add picture title to breadcrumb
        $picture_title = $CURRENT_PIC_DATA['title'] ? $CURRENT_PIC_DATA['title'] : strtr(preg_replace("/(.+)\..*?\Z/", "\\1", htmlspecialchars($CURRENT_PIC_DATA['filename'])), "_", " ");
        $breadcrumb .= ' > ' . $picture_title;
        $BREADCRUMB_TEXT .= ' > ' . $picture_title;
    }
*/

    // We remove the first ' > '
    $breadcrumb = substr_replace($breadcrumb,'', 0, 3);
    $BREADCRUMB_TEXT = substr_replace($BREADCRUMB_TEXT,'', 0, 3);
}


I left in by commented out a mod I wrote to add the file title or file name to the breadcrumb, which originally was written for this thread: http://forum.coppermine-gallery.net/index.php?topic=31889.0

wwwill

Is there any way to make things conditional.

For instance on the index and thumbnail pages I'd like the last item to not be bold and not a hyper link.

Please look atthe example of the breadcrumbs here:

http://www.nakedsoulchicago.com/sights_sounds/gameroom/
http://www.nakedsoulchicago.com/sights_sounds/gameroom/game/20694/PacMan.html

If I'm being too much of a pain justlet me know. I can live with Gallery layout the way it is. I'm just hoping to keep a consistant user interface.

Paver

#5
Heh.  I guess you're PHP skills don't involve looking at the scripts in question?   :P

Each script defines certain constants (right at the top or near the top for index.php), so various functions can tell who called them.  You have to be careful though, some like 'INDEX_PHP' are defined true in multiple scripts since certain language variables require this root variable to be true (I would personally like this changed, but there might be side effects I haven't considered yet), so you have to check the constants at the specific level first (check THUMBNAILS_PHP for specific code you want in it, then check INDEX_PHP for instance).

Here's an example:
    if (defined('DISPLAYIMAGE_PHP')) {
       $breadcrumb_out = '<span style="font-weight: bold;">' . $breadcrumb_last . '</span>';
    } elseif (defined('THUMBNAILS_PHP')) {
       $breadcrumb_out = strip_tags($breadcrumb_last);
    } elseif (defined('INDEX_PHP')) {
       $breadcrumb_out = strip_tags($breadcrumb_last);
    } else {
       $breadcrumb_out = $breadcrumb_last;
    }
    $breadcrumb .= ' > ' . $breadcrumb_out;

which replaces this line above:
$breadcrumb .= ' > ' . '<span style="font-weight: bold;">' . $breadcrumb_last . '</span>';

You could also possibly use $BREADCRUMB_TEXTS elements instead of using strip_tags(), but I haven't looked into the possible differences between these two arrays.  I suspect they are not supposed to be different, but I'm not sure.

By the way, you mentioned you modified index.php.  Ideally, you should keep all your mods in theme customizations and plugins so that upgrades in the future are easy (with no core scripts hacked by you).

wwwill