Breadcrumbs Script

A

Anonymous

Guest
Hi

I want to include breadcrumbs in my site and was wondering if a dynamic solution using PHP would be the most appropriate way to do it.

Any suggestions or links to suitable scripts?

Thanks :)
 
Navigation aids (Name from Hansel and Gretel analogy)

ex. Home > Subpage > SubSubPage
 
ahh.. multi-level navigation?
well: it would be the smartest thing to do it dynamic: plus that you can store everything in the database and give it likns by ID.. define parent_menu id in the database and you should be good to go :)
 
Ok, here you have a simple, but great example.
Done in 5 min. Damn.. it's even better than mine :(
Code:
<?php

// You can use $_SERVER['HTTP_HOST'] plus $_SERVER['REQUEST_URI']
$uri = "http://www.site.com/Subpage/SubSubPage/test.php?var=value";
$uri = explode('?', $uri);

// Now we have just
// http://www.site.com/Subpage/SubSubPage/test.php
$uri = $uri[0];
$uri_parts = explode('/', $uri);

// This to make http://www.site.com
$http_host = $uri_parts[0] . '//' . $uri_parts[2];

// We've got a new $uri_parts.
// Now we have Array ( [0] => Subpage [1] => SubSubPage [2] => test.php )
$uri_parts = array_slice($uri_parts, 3);

print '<a href="' . $http_host . '">Home</a>';

$up_folder = $http_host;
foreach($uri_parts as $uri_key => $uri_value) {
	$up_folder .= '/' . $uri_value;
	print ' » <a href="' . $up_folder . '">' . ucfirst($uri_value) . '</a>';
}

?>
And... a happy end: Home » Subpage » SubSubPage » Test.php

Hope it helps!
 
Oh Alexei sorry.. i forgot your theory: "Don't give whole code..."!
But this one was a great test for me... believe me :)
 
hehe gesf : it's okey, sometimes it's useful :)
anyways: that code could be tweaked so that it would use database for generating subpages and their corresponding menys as well :)
 
Back
Top