Snippet: Breadcrumbs
Version: 0.9c
Description:
This snippet was designed to show the path through the various levels of site structure back to the root. It is NOT necessarily the path the user took to arrive at a given page. Based on PageTrail snippet by: Bill Wilson.
You can download the code below. I’m also posting the changelog just incase anyone is interested.
Standard Disclaimer
I could be totally wrong.
Nice one Jaredc,
here is a little modification from me, to allow defining parameters on the snippet calling. I also add 2 more snippet parameters for user to define the title and description field to be used. If none specified, it will defaulted to pagetitle.
I haven’t tested this yet, so jaredc, feel free to change and modify it accordingly.
Sincerely,
Hm... makes the config section a little more cluttered than I am used to, but extends the capability of the snippet. To me, this seems like one of those snippets that you like to have be consistent throughout the site, so individualized instances with different parameters are probably not going to be used very often. Still, it doesn’t seem to hurt things so I don’t see why not.
As far as allowing the developer to to specify which field to use as the the title and description, I suppose that’s okay too. Though setting the default in the config section to "pagetitle" for both the $titleField and $decField doesn’t make much sense to me since the title and description will default to "pagetitle" if the desired field doesn’t exist regardless. I think I’ll change those to menutitle and description respectively. I think this will give the best "out of the box" behavior for most users. Those who want can change it.
Thanks for the input. I’ll get a 0.9b out soon. Do any PHP zealots out there know if adding a bunch of isset() variable checks will do much damage on speed? Doesn’t seem like it to me, but I thought I’d ask.
Standard Disclaimer
I could be totally wrong.
Quote from: Djamoer at Feb 24, 2006, 03:22 PM...it won’t suffer from performance issue...
Yeah. I didn’t think so. But I thought I’d ask. If I ask "stupid" questions long enough, eventually I’ll run out of them and that will have to mean I’m smart... right?
Anyway, the 0.9b version is now attached at the
top of the forum.
Standard Disclaimer
I could be totally wrong.
hi there, I had a problem using the breadcrumb snippet.
I don’t know if it is due to my special configuration, but I wanted to share it with you:
the parameters I defined as false ( as in showCrumbsAtHome=false ) didn_t work, because in the snippet the variable is treated as an boolean, but it actually is a string "false" and thus if ("false") evaluates as true.
After the Line
if(!isset($showCrumbsAtHome)) $showCrumbsAtHome = true;
I added a line
else if($showCrumbsAtHome== "false") $showCrumbsAtHome= false;
for all boolean parameters, and now it works great for me.