Breadcrumb in the page title

punctuation

Joined: 2012-12-11
Posts: 37
Posted: Wed, 2012-12-26 00:49

Could anyone post code on how to display: "Gallery > Album > Photo" in page title?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2012-12-26 12:37

breadcrumb code from page.html.php gallery3 3.0.2

        <? if ($theme->item() && !empty($parents)): ?>
        <ul class="g-breadcrumbs">
          <? $i = 0 ?>
          <? foreach ($parents as $parent): ?>
          <li<? if ($i == 0) print " class=\"g-first\"" ?>>
            <? // Adding ?show=<id> causes Gallery3 to display the page
               // containing that photo.  For now, we just do it for
               // the immediate parent so that when you go back up a
               // level you're on the right page. ?>
            <a href="<?= $parent->url($parent->id == $theme->item()->parent_id ?
                     "show={$theme->item()->id}" : null) ?>">
              <? // limit the title length to something reasonable (defaults to 15) ?>
              <?= html::purify(text::limit_chars($parent->title,
                    module::get_var("gallery", "visible_title_length"))) ?>
            </a>
          </li>
          <? $i++ ?>
          <? endforeach ?>
          <li class="g-active<? if ($i == 0) print " g-first" ?>">
            <?= html::purify(text::limit_chars($theme->item()->title,
                  module::get_var("gallery", "visible_title_length"))) ?>
          </li>
        </ul>
        <? endif ?>

3.0.4 page.html.php

        <? if (!empty($breadcrumbs)): ?>
        <ul class="g-breadcrumbs">
          <? foreach ($breadcrumbs as $breadcrumb): ?>
           <li class="<?= $breadcrumb->last ? "g-active" : "" ?>
                      <?= $breadcrumb->first ? "g-first" : "" ?>">
            <? if (!$breadcrumb->last): ?> <a href="<?= $breadcrumb->url ?>"><? endif ?>
            <?= html::purify(text::limit_chars($breadcrumb->title, module::get_var("gallery", "visible_title_length"))) ?>
            <? if (!$breadcrumb->last): ?></a><? endif ?>
           </li>
          <? endforeach ?>
        </ul>
        <? endif ?>

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
punctuation

Joined: 2012-12-11
Posts: 37
Posted: Wed, 2012-12-26 16:16

Thanks.
I modify it a litte bit, and this works for me:

Quote:

<title>

<? if ($theme->item()->id == 1): ?>
<?= html::purify(text::limit_chars($theme->item()->title,
module::get_var("gallery", "visible_title_length"))) ?>

<? else: ?>

<? if ($theme->item() && !empty($parents)): ?>
<? $i = 0 ?>
<? foreach ($parents as $parent): ?>
<? if ($i == 0) ?>
<?= html::purify(text::limit_chars($parent->title,
module::get_var("gallery", "visible_title_length"))) ?> >
<? $i++ ?>
<? endforeach ?>

<? if ($i == 0) ?>
<?= html::purify(text::limit_chars($theme->item()->title,
module::get_var("gallery", "visible_title_length"))) ?>

<? endif ?>
<? endif ?>

</title>

 
punctuation

Joined: 2012-12-11
Posts: 37
Posted: Thu, 2012-12-27 02:31

After playing with this some more, I find this even better solution because if works with tags also:


  <title>

          <? if ($theme->item()->id == 1): ?>
          <?= html::purify($theme->item()->title) ?>
          
           <? else: ?>
              
          <? if (!empty($breadcrumbs)): ?>
          <? foreach ($breadcrumbs as $breadcrumb): ?> 
           <? if (!$breadcrumb->last): ?><? endif ?>
            <?= html::purify($breadcrumb->title) ?> 
           <? if (!$breadcrumb->last): ?> > <? endif ?>
           <? endforeach ?>
          <? endif ?>
          <? endif ?>

   </title>

 
betandallas
betandallas's picture

Joined: 2012-10-29
Posts: 2
Posted: Thu, 2012-12-27 20:42

Punctuation,
Is there any tool that can help validate/preview the breadcrumb above?
I have created new gallery on my website (wordpress based) and would like little help.
Thanks
Michelle

 
punctuation

Joined: 2012-12-11
Posts: 37
Posted: Fri, 2012-12-28 02:09

I don't know much, I know just enough to modify the code. This works for Gallery3.
Don't quite understand your question. Are you using wordpress plugin to pull photos from Gallery3 and you want to display "Gallery > Album > Photo" on your wordpress site in page title?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2012-12-28 02:14

I think she is likely a spammer.
But my WordPress G3 plugin already has breadcrumbs.

-s
________________________________
All New jQuery Minislideshow for G2/G3