Breadcrumbs - how to remove last link (to page itself)?

Matt
Joined: 14 Nov 2009

Breadcrumbs - how to remove last link (to page itself)?

Posted:14 Nov 2009 (05:57 UTC)
Hi, all

My first question on this forum: I'm polishing my custom re-styling of bitweaver v2.

I don't like that the last breadcrumb links to the page itself.

If current page title is present at the end of the breadcrumbs (this being a matter of preference) it definitely should not be a link. I'd like to be able to remove the last breadcrumb title completely (i.e. no breadcrumbs if I'm on top of a Wiki Book structure).

Is there a way to include a condition in the template code? what variables should I use?
My experience with Bitweaver is maybe a month old, I'm a webmaster but not a PHP programmer and I'm still missing a lot of what's possible and what's not.

Thanks

Matt
laetzer
Joined: 15 Mar 2004

Re: Breadcrumbs - how to remove last link (to page itself)?

Posted:14 Nov 2009 (16:16 UTC)
Depends which breadcrumb. The one for wiki pages (organized in "books"):

1. Examine the page for the code you want to change: the wiki breadcrumb is wrapped into a div class='structurbar' ... search the codebase for that code.

2. This reveals, that the breadcrumb is built in a template called bitweaver/liberty/templates/display_structure.tpl

3. Copy this template from the above location to: bitweaver/themes/styles/NAME-OF-YOUR-STYLE/liberty/

4. During development, make sure CSS and JS packing and joining is deactivated (Admin > Themes > Settings), and also smarty_force_compile is set to TRUE in bitweaver/kernel/config_inc.php

5. Now you can change the template code to only take those details from the array of possible details, that you want the user to see. Smarty code is like HTML with loops, so trial and error. You might have to examine the PHP-file that's providing the array ($structureInfo) which is looped here. Actually, I'm not sure how to do this without changing the PHP-code in this case ... you should update us on your findings. (:

Similiar for Fisheye (image galleries) and other possible breadcrumbs.
Matt
Joined: 14 Nov 2009

Re: Breadcrumbs - how to remove last link (to page itself)?

Posted:16 Nov 2009 (01:29 UTC)
laetzer, thank you for your reply. I have eventually found some time today to play with the smarty template.

I was trying to include a condition for the Wiki structure loop, found in the display_structure.tpl file, just as you suggested above.

In the templates/center_wiki_page.tpl I have found the variable that shows the page title, it looks like this:
<div class="header"><h1>{$gContent->mInfo.title|escape}</h1></div>


So I added an extra condition for the structure loop. This condition compares the title of the current page with the title found in the breadcrumb and shows the latter if they are not equal.
NOTE that this is a very rough method. What will happen, if you have any other page with the same title in a single structure, its name will be SKIPPED in breadcrumbs.

Here's the altered code:
{section loop=$structureInfo.structure_path name=ix}
{if $gContent->mInfo.title|escape neq $structureInfo.structure_path[ix].title|escape}
{if $structureInfo.structure_path[ix].parent_id} &raquo; {/if}
<a href="index.php?structure_id={$structureInfo.structure_path[ix].structure_id}">
{$structureInfo.structure_path[ix].title|escape}
</a>
{/if}
{/section}


For everybody who want to keep the title, but remove the link, just add an ELSE condition to the loop and remove the html link tag - I didn't bother since I don't need it.

I'm still going to have to find a way to remove the div with the path completely, if I'm at the top of the structure. I'll post it here when (if) I find out how. Any ideas? - please post :)
Matt
Joined: 14 Nov 2009

Re: Breadcrumbs - how to remove last link (to page itself)?

Posted:16 Nov 2009 (04:08 UTC)
A slight modification of the code. What this one does, it displays the arrow at the end of the breadcrumbs, which visually improves usability:
{section loop=$structureInfo.structure_path name=ix}
{if $gContent->mInfo.title|escape neq $structureInfo.structure_path[ix].title|escape}
<a href="index.php?structure_id={$structureInfo.structure_path[ix].structure_id}">
{$structureInfo.structure_path[ix].title|escape}
</a>
<span> &raquo; </span>
{/if}
{/section}


Result on your pages:



Main WikiBook Page > Sub Page > Sub Subpage >

Current Page Title

Page content...



HTH
  Page 1 of 1  1 
Post
If you are already registered, please enter your login credentials.
Anonymous Post