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
https://forums.phpfreaks.com/topic/239904-breadcrumbs-help/
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
https://forums.phpfreaks.com/topic/239904-breadcrumbs-help/#findComment-1232332
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.