Changing the "home"-link in breadcrumb

dreamingof8a

Joined: 2005-05-22
Posts: 69
Posted: Thu, 2005-05-26 10:11

Hi!
Is it possible to change the URL of the "home"-link in breadcrumb via the admin-area?
Thanx, Felix

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2005-05-26 13:15

You need to edit the template files for this. For your layout you'd edit create a local directory under the templates directory of the layout you are using. Then you'd copy pathbar.tpl into the local directory and edit the area that starts with <ul class="gbBreadCrumb">

Here's what I changed on mine to add a "home" link to the beginning of the bar.

From this:

  <ul class="gbBreadCrumb">
    {section name=parent loop=$layout.parents}
    <li{if $smarty.section.parent.first} class="firstChild"{/if}>
      {if !$smarty.section.parent.last}
	<a href="{g->url arg1="view=core:ShowItem" arg2="itemId=`$layout.parents[parent].id`"
	 arg3="highlightId=`$layout.parents[parent.index_next].id`"}">
	  {$layout.parents[parent].title|default:$layout.parents[parent].pathComponent|markup}
	</a>
      {else}
	<a href="{g->url arg1="view=core:ShowItem" arg2="itemId=`$layout.parents[parent].id`"
	 arg3="highlightId=`$layout.item.id`"}">
	  {$layout.parents[parent].title|default:$layout.parents[parent].pathComponent|markup}
	</a>
      {/if}
    </li>
    {/section}
    <li{if empty($layout.parents)} class="firstChild"{/if}>
      {$layout.item.title|default:$layout.item.pathComponent|markup}
    </li>
  </ul>

To this:

  <ul class="gbBreadCrumb">
    {section name=parent loop=$layout.parents}
    <li{if $smarty.section.parent.first} class="firstChild"{/if}>
      <a href="/">Home</a>
    </li>
    <li>
      {if !$smarty.section.parent.last}
        <a href="{g->url arg1="view=core:ShowItem" arg2="itemId=`$layout.parents[parent].id`"
         arg3="highlightId=`$layout.parents[parent.index_next].id`"}">
          {$layout.parents[parent].title|default:$layout.parents[parent].pathComponent|markup}
        </a>
      {else}
        <a href="{g->url arg1="view=core:ShowItem" arg2="itemId=`$layout.parents[parent].id`"
         arg3="highlightId=`$layout.item.id`"}">
          {$layout.parents[parent].title|default:$layout.parents[parent].pathComponent|markup:stripBbcodeAndHtml}
        </a>
      {/if}
    </li>
    {/section}
    <li class="firstChild">
      <a href="/">Home</a>
    </li>
    <li>
      {$layout.item.title|default:$layout.item.pathComponent|markup}
    </li>
  </ul>
 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Mon, 2005-09-05 04:40

Hello nivekiam,

I want to do what you wrote above, add HOME before the Gallery navigation link on top.

But I cannot find the pathbar.tpl that you mentioned.

I am using the Classic Theme. Where is this pathbar.tpl that I need to copy to my Local folder (themes/classic/templates/local)

Alex

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2005-09-05 04:55

I'm pretty sure this is old stuff from before the new (current) theme system. Meaning pathbar.tpl doesn't exist anymore.

Without looking, I believe that stuff is in /modules/core/templates/blocks/BreadCrumb.tpl

You can either create a 'local' directory in that blocks directory and copy BreadCrumb.tpl into it and edit it there, but it might be better (to keep all of you edits in one place) to copy the BreadCrumb.tpl into your theme's templates directory then edit theme.tpl and change this: {g->block type="core.BreadCrumb"}
to this {g->theme include="BreadCrumb.tpl"}

You'd put theme.tpl into your 'local' directory and maybe BreadCrumb.tpl, but play around with that, I'm not sure if it needs to be in the /templates directory to be found or if it can be in the /templates/local directory.

You might also want to look at cloning the Classic theme into your own theme. I assume, from your posts, you've seen these pages on editing themes in G2:
http://codex.gallery2.org/index.php/Gallery2:Themes
http://codex.gallery2.org/index.php/Gallery2:Tpl_Reference

As well as the Sticky topic at the top of the G2 Customization forum.

I only mention that since is seems you're doing quite a bit of editing of a theme that ships with Gallery.

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Mon, 2005-09-05 05:48

Ok!! But if the code you gave above was for the pathbar.tpl which doesn't exist anymore, then what is the code that I need to change or insert into the BreadCrumb.tpl in order to add the HOME link BEFORE the Gallery Link?

PS: As you can see, (since I found this old Post) that I AM TRYING to look around for answers!! :D :wink: :P :D :)

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2005-09-05 06:38

Ah yes, the code is a bit different. Here's what I used to create a "home" link

<div class="{$class}">
  <a href="/" class="BreadCrumb-1">Home</a>
  {section name=parent loop=$theme.parents}
  {if !$smarty.section.parent.last}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
                   arg3="highlightId=`$theme.parents[parent.index_next].id`"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
  {else}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
                   arg3="highlightId=`$theme.item.id`"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
  {/if}
  {if isset($separator)} {$separator} {/if}
  {/section}
  {if ($theme.pageType == 'admin' || $theme.pageType == 'module')}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.item.id`"}">
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}</a>
  {else}
  <span>
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}
  </span>
  {/if}
</div>

This is the original code

<div class="{$class}">
  {section name=parent loop=$theme.parents}
  {if !$smarty.section.parent.last}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
		   arg3="highlightId=`$theme.parents[parent.index_next].id`"}"
     class="BreadCrumb-{counter name="BreadCrumb"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}
  </a>
  {else}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
		   arg3="highlightId=`$theme.item.id`"}"
     class="BreadCrumb-{counter name="BreadCrumb"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}
  </a>
  {/if}
  {if isset($separator)} {$separator} {/if}
  {/section}

  {if ($theme.pageType == 'admin' || $theme.pageType == 'module')}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.item.id`"}" class="BreadCrumb-{counter name="BreadCrumb"}">
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}
  </a>
  {else}
  <span class="BreadCrumb-{counter name="BreadCrumb"}">
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}
  </span>
  {/if}
</div>

As you can see I added my "home" link to the beginning of the code, then removed all instances of class="BreadCrumb-{counter name="BreadCrumb"}" and then I also moved </a> onto the same line as the link so there wasn't a space at the end of each link.

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Mon, 2005-09-05 20:22

Wooo hoo!! It worked!!

The BreadCrumb.tpl file went into classic/templates/local

Thanks again!!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-05 20:48

nivekiam, do you mind adding this information to the codex...somewhere? maybe as a G2 modification on the user contribution page, add either a link to this thread or to a dedicated codex page.
thanks! :)

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2005-09-05 20:54

Sure, no problem.

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Mon, 2005-09-05 21:39

Cool... now I felt useful!!!

I think you should also add the codes for renaming files to aaa_001, etc...

gallery2/modules/core/classes/helpers/GalleryItemHelper_medium.class


AFTER:

    function addItemToAlbum($fileName, $itemName, $title, $summary,
			    $description, $mimeType, $albumId, $symlink=false) {
	global $gallery;

	$platform = $gallery->getPlatform();

ADD

	list ($base, $extension) = GalleryUtilities::getFileNameComponents($fileName); 
	$itemName = 'aaa' . $extension; 

THEN ADD THE FOLLOWING RIGHT AFTER THAT IF YOU DON'T WANT TITLE, SUMMARY AND DESCRIPTION TO PICK UP THE ORIGINAL FILENAME:

	$title = ""; 
	$summary = ""; 
	$description = ""; 

Then also change the follwing to make sure can can upload more than 100 pics to an Album without getting an error:

gallery2/modules/core/classes/helpers/GalleryFileSystemEntityHelper_medium.class


    if (++$retry > 1000) {
		return array(GalleryStatus::error(ERROR_COLLISION, __FILE__, __LINE__), null);

CHANGE THE 100 to 1000

Thanks!
Alex

 
anonymous11234

Joined: 2002-12-05
Posts: 135
Posted: Fri, 2005-10-14 17:09

Nevermind I got it.

 
geddeth
geddeth's picture

Joined: 2004-05-16
Posts: 52
Posted: Tue, 2005-11-15 20:22

Here's what I did - it makes the Home link also show up on the fron page of G2.

<div class="{$class}">
  {section name=parent loop=$theme.parents}
  {if $smarty.section.parent.index == 0}
    <a href="/"  class="BreadCrumb-{counter name="BreadCrumb"}">Home</a>
  {/if}
  {if !$smarty.section.parent.last}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
		   arg3="highlightId=`$theme.parents[parent.index_next].id`"}"
     class="BreadCrumb-{counter name="BreadCrumb"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
  {else}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
		   arg3="highlightId=`$theme.item.id`"}"
     class="BreadCrumb-{counter name="BreadCrumb"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
  {/if}
  {if isset($separator)} {$separator} {/if}
  {/section}

  {if ($theme.pageType == 'admin' || $theme.pageType == 'module')}
  <a href="{g->url arg1="view=core.ShowItem"
		   arg2="itemId=`$theme.item.id`"}" class="BreadCrumb-{counter name="BreadCrumb"}">
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}</a>
  {else}
  {if $smarty.section.parent.index == 0}
    <a href="/"  class="BreadCrumb-{counter name="BreadCrumb"}">Home</a>
  {/if}
  <span class="BreadCrumb-{counter name="BreadCrumb"}">
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}</span>
  {/if}
</div>

HTH.

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Fri, 2005-12-02 18:04

Nice one Geddeth!

I was able to implement your code in my Breadcrumb.tpl file. Made two additions to add the separator as with the code you gave, the separator does not come up. Those that don't want a separator can switch it off in theme admin.

<div class="{$class}">
  {section name=parent loop=$theme.parents}
  {if $smarty.section.parent.index == 0}
    <a href="/"  class="BreadCrumb-{counter name="BreadCrumb"}">Home</a>
  {if isset($separator)} {$separator} {/if}
  {/if}
  {if !$smarty.section.parent.last}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
               arg3="highlightId=`$theme.parents[parent.index_next].id`"}"
     class="BreadCrumb-{counter name="BreadCrumb"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
  {else}
  <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[parent].id`"
               arg3="highlightId=`$theme.item.id`"}"
     class="BreadCrumb-{counter name="BreadCrumb"}">
    {$theme.parents[parent].title|default:$theme.parents[parent].pathComponent|markup:strip}</a>
  {/if}
  {if isset($separator)} {$separator} {/if}
  {/section}

  {if ($theme.pageType == 'admin' || $theme.pageType == 'module')}
  <a href="{g->url arg1="view=core.ShowItem"
                arg2="itemId=`$theme.item.id`"}" class="BreadCrumb-{counter name="BreadCrumb"}">
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}</a>
  {else}
  {if $smarty.section.parent.index == 0}
    <a href="/"  class="BreadCrumb-{counter name="BreadCrumb"}">Home</a>
  {if isset($separator)} {$separator} {/if}
  {/if}
  <span class="BreadCrumb-{counter name="BreadCrumb"}">
     {$theme.item.title|default:$theme.item.pathComponent|markup:strip}</span>
  {/if}
</div>
 
Fuji86
Fuji86's picture

Joined: 2006-02-16
Posts: 12
Posted: Thu, 2006-03-16 12:08

Thanks!

 
randomly

Joined: 2006-07-06
Posts: 13
Posted: Thu, 2006-07-06 11:42

I am wondering how I can limit the BreadCrumb and SystemLinks so that they both span a certain width of the page (say 990). I tried to use a table but it turned out that the contain of the page became centralized which I dislike. Anyone knows how?

Moreover, I want to put a "slideshow link" in the middle of the NavBar when the gallery is showing the photos (not albums). How can I do that?

-Randomly

 
ericob

Joined: 2003-10-14
Posts: 17
Posted: Mon, 2007-02-05 06:39

Adding "Home" is not quite working for me. The BreadCrumb.tpl file I'm editing is "Revision 15342" and is not built quite the way quoted above. The link itself works, but the display of the breadcrumbs is wrong. There are various incorrect results. In the worst case "Home" is interposed between nearly every album and and item. Like this:

Home » Photo Portfolio » Home » Fine Art » Home » Flora » Home » Flowers » Sunflower 4572

It should look like this:

Home » Photo Portfolio » Fine Art » Flora » Flowers » Sunflower 4572.

Thoughts?

 
ericob

Joined: 2003-10-14
Posts: 17
Posted: Fri, 2007-02-16 07:52

To answer my own question [note that I simply wanted to add a "Home" link at the beginning of the breadcrumbs, nothing more...]

To add a permanent "Home" link at the beginning of the breadcrumbs:

In modules/core/templates/blocks/ create a new folder named "local"
copy BreadCrumb.tpl to that new "local" directory and, near the top of the copied file, ADD something like this:

<a href="/" class="BreadCrumb-{counter name="BreadCrumb"}">Home</a>
{if isset($separator)} {$separator} {/if}

BETWEEN these two line

<div class="{$class}">
{foreach name=parent from=$theme.parents item=parent}

So it ends up looking like:

<div class="{$class}">
<a href="/" class="BreadCrumb-{counter name="BreadCrumb"}">Home</a>
{if isset($separator)} {$separator} {/if}
{foreach name=parent from=$theme.parents item=parent}

Note that you can change the url to something other than "/" if you need the "Home" link to go somewhere other than to the top level of your site. You are also free to use a word other than "Home."

Unfortunately, this is a Gallery-wide modification which means that if you have a multi site installation "Home" is going to appear in EVERY gallery and always point to the same url.

It would be nicer if this change could be accomplished locally at the level of each album.

 
gaynormcc
gaynormcc's picture

Joined: 2003-09-05
Posts: 426
Posted: Fri, 2007-02-16 11:45

A bit amused at myself answering this cos the code you are using is way beyond me :)
However, I agree with you.

I have solved this to some extent by using the Logo as the "Back to the Homepage" and changing the logo for specific Colorpacks for individual sites.
Rather time consuming. Far easier to use the links we can put in the breadcrumb line,
Besides all my clients fall into two township categories, so I just have the two townships' directory pages as the "Home" pages, and let them navigate from there.

Probably not awfully helpful to you. :)

Gaynor

 
ayhopkins

Joined: 2004-08-21
Posts: 7
Posted: Wed, 2007-04-25 20:34

That is funny. Your fix works perfectly, but I can only get it to work by placing "local" into my special "mysite/templates" directory. If I try to place it globally I get a Security error.

But I get a weird php warning in my apache web logs (getting large).

PHP Notice: Undefined index: class in <SMARTY-DIRECTORY-PATH>BreadCrumb.tpl.php on line 5

I assume it refers to the $class line in BreadCrumb.tpl

And it only happens the first time you go forward in the BreadCrumb path not backwards.