Jump to content

Breadcrumbs Help


barrycorrigan

Recommended Posts

Hi Everyone,

 

I have wrote this small script to display some simple breadcrumbs I was wondering how could I get rid of the .php extenstion. And was also wondering if this is the correct way of doing things. I'm new to php so any advice would be great: Here is the code

 

<?php
$pagetitle = basename($_SERVER['SCRIPT_NAME']);;
$ul_id='breadcrumbs';
echo '<ul id="'.$ul_id.'"><li class="first"><a href="/">Home</a></li>';
echo '<li><a class="selected" href="'.$pagetitle.'">'.$pagetitle.'</a></li>';
echo '</ul>';
?>

 

Thanks

 

Barry

Link to comment
Share on other sites

Using the SCRIPT_NAME as your title is certainly not the way to do it. Plus your code is very static/restricted, despite pulling in the title dynamically. It will only ever work for "Home > thispage" - and the page name as mentioned, if based off of the script name, wouldn't look very good (and possibly not even make sense to the user).

 

It's hard to say how this should be done really, as we know nothing about the navigation structure of your site. When using content from a database it's generally the case to dynamically generate them, but in other cases you may need to set them up yourself. Either way you should only set the breadcrumbs at the highest level within each controller/page's PHP code, and have centralized logic that would handle everything else.

 

If you post more information we can help you further.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.