Improved breadcrumbs plugin

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
arl

Improved breadcrumbs plugin

Post by arl »

I have added a few options to the breadcrumbs plugin so that I can use it on my site without have to hack the source. ;-)

Options are:
  • delimiter: Text to seperate entries in the list. The default is ">>" but you can change it to anything.
  • initial: Boolean to specify if the list should start with a delimiter before the first entry.
  • root: Page alias of a page you want to always appear as the first page in the list. Can be used to make a page (e.g. the front page) appear to be the root of everything even though it is not.
I have attached the source to this message. This version is in use on www.bogong.dk, using all 3 options.

Wishy: Any chance to have this included in the next release? It should be a drop-in replacement with default behaviour identical to the old one. And the code changes are trivial so you should be able to easily check the code for errors.

[attachment deleted by admin]
Last edited by arl on Tue Aug 30, 2005 7:46 pm, edited 1 time in total.
jah
Forum Members
Forum Members
Posts: 147
Joined: Thu Dec 30, 2004 9:09 am

Re: Improved breadcrumbs plugin

Post by jah »

Thanks! I liked this a lot. :-). It works for me.

Jon
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Improved breadcrumbs plugin

Post by Ted »

I've added this to my todo list.  It looks like some nice additions.

Thanks!
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Improved breadcrumbs plugin

Post by Ted »

I finally added this to svn.  Thanks again!
koehler

Re: Improved breadcrumbs plugin

Post by koehler »

Please also make it possible to add css to the breadcrumbs, 
for example Root >> Path1 >> current
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Improved breadcrumbs plugin

Post by Ted »

How should I do it?  Root Path1, etc?
koehler

Re: Improved breadcrumbs plugin

Post by koehler »

No, that would lead into heavy setup issues for indefinitely long paths.

Maybe, there could be something like a increase/decrease factor,
for example when using font-weight for level ascending:

$weight += 100;
$style = 'style="font-weight: '.$weight.'"';

then where the $trail's are assigned we could put this
$style into an account with a present tag.

What do you think ?
perl4ever

Re: Improved breadcrumbs plugin

Post by perl4ever »

Well, I hope no one minds.  I've played a bit with the breadcrumbs - love it.  But, found a small bug, and also wanted to have more CSS control.  So, I have created a revision.  I am including it here, with my documentation:

# Revisions explained
# 04 Sept 2005 :: Tomas Hood (perl4ever@hotmail.com)
#
#              1.  Added ability to set CSS class by passing parameter
#                /classid='name_of_css_class'/
#
#                example:
# in css style sheet, define .breadcrumb, then define
# a.breadcrumb:active, a.breadcrumb:link, a.breadcrumb:visited, etc
# then put {breadcrumb class='breadcrumb'} in your template
#
#              2.  Fixed small bug in defining 'root' parameter.
#                  If in sub-level, and root is defined as the real
#                  root, then root is shown twice.  Now it won't.
#


[attachment deleted by admin]
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Improved breadcrumbs plugin

Post by Ted »

Thanks for these fixes.  They're in svn.
perl4ever

Re: Improved breadcrumbs plugin

Post by perl4ever »

Ok - I just discovered a more complex "bug" -- one that does not yet seem easily solvable.

In the breadcrumbs code, the following exists:

global $gCms;
$thispage = $gCms->variables['page'];

This will work when you are navigating via the bullet menu, or other menu paths, from what I can tell.  However, let's say that on your main page (let's call it 'homepage'), you have some News (module) items.  They, in turn, have links to the "full" text of each News item.  If a user follows one of THOSE links, then the variables['page'] remains as 'homepage' and does NOT get changed to some other page.

This is because the content is dynamic - there is no "alias" and no page name associated with this dynamic content.  So, now, the breadcrumbs logic breaks down.  You simply see "Home Page" on the breadcrumbs - and no link TO the home page, because it thinks it is still at the home page.

I've explored a bit - and see no obvious quick fix.

I'd like to have some pointers as to what I might look for, to fix this up...

Thanks.
arl

Re: Improved breadcrumbs plugin

Post by arl »

I have made a couple of changes:

1) Bugfix: If the current page does not exist (e.g. if this tag is used in the template that is used to display "page not found" pages) then it would generate a PHP error.

2) Bugfix: The initial and root parameters would be ignored if the page was not found.

3) The last changes by perl4ever modified default behaviour of the tag by removing around the current page title. I have put them back again. We might need to find a more flexible solution using a CSS class, but just silently removing them is not the way to go.

Allan

[attachment deleted by admin]
perl4ever

Re: Improved breadcrumbs plugin

Post by perl4ever »

RE:  The removal of

Yup -- my bad!  Long day looking at the screen.  That slipped by.

Apologies, and thanks for noting that and fixing it!

E-gads!  I just looked and realized that I also messed up with another small item - and it could really confuse someone.

In the "help" text, I did not escape the greater than and less than around the 'a href'.  Would you change those to the escaped chars?

See what happens late late at night?
Last edited by perl4ever on Wed Sep 07, 2005 4:31 am, edited 1 time in total.
arl

Re: Improved breadcrumbs plugin

Post by arl »

Yeah, it is dangerous working late, but one tends to get so much stuff done at that time of day. :-)

Regarding : I was just wondering if the best solution would be to add another parameter, say "currentclassid", then if currentclassid is set we wrap the current page name in , otherwise we wrap it in . That would not alter the default behaviour but it would allow those in need to do whatever they want with the formatting.

Personally I am happy with the formatting, but if anybody needs more control I'd be happy to add those few lines of code.

What do you think of that idea?

Allan
perl4ever

Re: Improved breadcrumbs plugin

Post by perl4ever »

I *do* like that idea of a default with a configurable alternative.  You have my vote to make that change.
arl

Re: Improved breadcrumbs plugin

Post by arl »

I have added the "currentclassid" parameter, cleaned up the code a little and fixed a couple of possible bugs.

Allan

[attachment deleted by admin]
Locked

Return to “Modules/Add-Ons”