Advanced search  

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

Pages: [1]   Go Down

Author Topic: Output breadcrumb in CUSTOM_HEADER  (Read 5465 times)

0 Members and 1 Guest are viewing this topic.

wwwill

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Output breadcrumb in CUSTOM_HEADER
« on: June 12, 2006, 11:29:13 am »

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.
Code: [Select]
<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}
« Last Edit: June 15, 2006, 01:24:32 am by Paver »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Output breadcrumb in CUSTOM_HEADER
« Reply #1 on: June 12, 2006, 08:19:08 pm »

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

Add the mod block just before the last line:
Code: [Select]
    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):
Code: [Select]
    // 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).
Logged

wwwill

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Output breadcrumb in CUSTOM_HEADER
« Reply #2 on: June 12, 2006, 10:18:37 pm »

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://forum.coppermine-gallery.net/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

Code: [Select]
                    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.
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Output breadcrumb in CUSTOM_HEADER
« Reply #3 on: June 12, 2006, 10:54:04 pm »

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:
Code: [Select]
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
Logged

wwwill

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Output breadcrumb in CUSTOM_HEADER
« Reply #4 on: June 13, 2006, 02:11:00 am »

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

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Output breadcrumb in CUSTOM_HEADER
« Reply #5 on: June 13, 2006, 03:18:55 am »

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:
Code: [Select]
    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:
Code: [Select]
$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).
« Last Edit: June 13, 2006, 03:24:08 am by Paver »
Logged

wwwill

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: Output breadcrumb in CUSTOM_HEADER
« Reply #6 on: June 15, 2006, 01:08:59 am »

Awesome. That worked. Thanks much. ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 19 queries.