Jump to content

Archived

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

vbnullchar

bread crumb navigation

Recommended Posts

anyone has a bread crumb script?
that can make something like this

[code]PHP Freaks Forums >> PHP and MySQL >> PHP Help >> Start new topic[/code]

Share this post


Link to post
Share on other sites
There's a couple of nice ones here:

[url=http://www.hotscripts.com]Hotscripts[/url]

Regards
Huggie

Share this post


Link to post
Share on other sites
Did you try this one, it's advanced and has lots of configurable options...

http://www.baskettcase.com/classes/breadcrumb/

If it's not what you're after, perhaps a better explanation is in order?

Regards
Huggie

Share this post


Link to post
Share on other sites
still no. 

I wanted to create a navigation similar to this, where you can just click the previous level

PHP Freaks Forums > PHP and MySQL > PHP Help > bread crumb navigation

Share this post


Link to post
Share on other sites
There you go hope it will help you

<?php
$id = $_GET['id'];
if ( strlen( $id ) < 1 )
$id = "home";

$pages = array(
home => array( id=>"home", parent=>"", title=>"Home",
url=>"showpage.php?id=home" ),
users => array( id=>"users", parent=>"home", title=>"Users",
url=>"showpage.php?id=users" ),
jack => array( id=>"jack", parent=>"users", title=>"Jack",
url=>"showpage.php?id=jack" )
);

function breadcrumbs( $id, $pages )
{
  $bcl = array( );
  $pageid = $id;
  while( strlen( $pageid ) > 0 )
  {
$bcl[] = $pageid;
$pageid = $pages[ $pageid ]['parent'];
  }
  for( $i = count( $bcl ) - 1; $i >= 0; $i-- )
  {
$page = $pages[$bcl[$i]];
if ( $i > 0 )
{
echo( "<a href=\"" );
echo( $page['url'] );
echo( "\">" );
}
echo( $page['title'] );
if ( $i > 0 )
{
echo( "</a> | " );
}
  }
  }
  ?>
  <html>
  <head>
  <title>Page - <?php echo( $id ); ?></title>
  </head>
  <body>
  Breadcrumbs: <?php breadcrumbs( $id, $pages ); ?><br/>
  Page name: <?php echo( $id ); ?>
  </body>
  </html>

Share this post


Link to post
Share on other sites
[quote author=vbnullchar link=topic=111046.msg449746#msg449746 date=1160477889]
still no. 

I wanted to create a navigation similar to this, where you can just click the previous level

PHP Freaks Forums > PHP and MySQL > PHP Help > bread crumb navigation
[/quote]

OK, I don't know if you didn't read the page where I sent you or just didn't understand, but the link I posted was to some code for breadcrumb navigation that allows you to click the previous levels.  There were even over 25 examples when showing the different options with the code.

I think I'm going to have to bail out of this one, good luck with finding what you're after

Regards
Huggie

Share this post


Link to post
Share on other sites
Store the bread crumbs in an array like this: [code]$nav[] = array('Main page','index.php');
$nav[] = array('Some other page','index.php?page=some_other');
$nav[] = array('Yet another page');[/code]

Then when generating the bread crumbs do this: [code]<?php
foreach($nav as $bc)
{
$nav2[] = empty($bc[1]) ? $bc[0] : "<a href='{$bc[1]}'>{$bc[0]}</a>";
}

echo "<div id='bread_crumbs'>".join(' &gt; ',$nav2)."</div>";
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.