Jump to content

Recommended Posts

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>
[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
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]
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.