how to add item to breadcrumb

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

how to add item to breadcrumb

Post by aneuryzma »

Hi,

I have a breadcrumbs bar and I want to dynamically add the items to it.
I was wondering how to assign the current page <title> tag into the breadcrumb.
I can easily add the link to the current page using $_SERVER[PHP_SELF];

thanks

Code: Select all

<?php
$currentPage = $_SERVER[PHP_SELF];
?>
 
<div id="breadcrumb">
    <a id="primaBread" href="index.php">Home page</a>
    <a href="<?php echo $currentPage ?>"><?php echo $currentPage ?></a>
</div>
Last edited by Benjamin on Sun May 17, 2009 9:29 am, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
Gabriel
Forum Commoner
Posts: 41
Joined: Wed May 06, 2009 8:12 pm
Location: Las Vegas

Re: how to add item to breadcrumb

Post by Gabriel »

PHP_SELF is a server variable that is returned to PHP by the web server. So unfortunately, you won't be able to retrieve the title tags without them being assigned by a variable of a sort. Set your title to a variable and call the variable in your breadcrumbs bar. There are other ways but I'd need to know more information about how your website displays pages and what-not.
Post Reply