Web Design Forum: Bread crumb not showing - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Bread crumb not showing Rate Topic: -----

#1 User is offline   sash_007 

  • Trap Grand Marshal Member
  • PipPipPipPip
  • Group: Members
  • Posts: 638
  • Joined: 18-July 09
  • Reputation: 5
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 10 March 2010 - 03:53 AM

Hello friends,



I have added breadcrumb navigation to mypage

but its is'nt showing

i have use the following php

<div id="content"><!-- content start -->

<?php
session_start();
include("includes/Breadcrumb.inc.php");
$trail = new Breadcrumb();
$trail->add('Home', $_SERVER['PHP_SELF'], 0);

//Sample CSS
echo "
<style>
#breadcrumb ul li{
   list-style-image: none;
   display:inline;
   padding: 0 3px 0 0;
   margin: 3px 0 0 0;
}
#breadcrumb ul{
   margin:0;padding:0;
   list-style-type: none;
   padding-left: 1em;
}
</style>
";

//Now output the navigation.
$trail->output();
?>
<div class="col1 item itemOdd" id="contentBlock">
<div class="c7">



and used this include

<?php
/*
* Breadcrumb navigation class
* Mick Sear
* http://www.ecreate.co.uk
*
* The key to using this is to decide on a $level for each page.  (array, starting position 0)
* This determines where in the trail a link will be placed.  So, I normally make the homepage level 0,
* then every page that can be accessed from the top level nav becomes level 1, and every page
* from that second level becomes level 2, and so on.  When users return to a higher level (e.g. level 1)
* the surplus links are removed.  Only one page can occupy a $level in the crumb trail.
* There might be several routes to a page.  In which case, the trail will reflect the route that the
* user actually took to get to that page.
*/

class Breadcrumb{

   var $output;
   var $crumbs = array();
   var $location;


   /*
    * Constructor
    */
   function Breadcrumb(){  
   
      if ($_SESSION['breadcrumb'] != null){
         $this->crumbs = $_SESSION['breadcrumb'];
      }  
   
   }

   /*
    * Add a crumb to the trail:
    * @param $label - The string to display
    * @param $url - The url underlying the label
    * @param $level - The level of this link.  
    *
    */
   function add($label, $url, $level){

      $crumb = array();
      $crumb['label'] = $label;
      $crumb['url'] = $url;

      if ($crumb['label'] != null && $crumb['url'] != null && isset($level)){       
            
         while(count($this->crumbs) > $level){

            array_pop($this->crumbs); //prune until we reach the $level we've allocated to this page

         }

         if (!isset($this->crumbs[0]) && $level > 0){ //If there's no session data yet, assume a homepage link

            $this->crumbs[0]['url'] = "/index.php";
            $this->crumbs[0]['label'] = "Home";

         }

         $this->crumbs[$level] = $crumb;  
               
      }

        $_SESSION['breadcrumb'] = $this->crumbs; //Persist the data
        $this->crumbs[$level]['url'] = null; //Ditch the underlying url for the current page.
   }

   /*
    * Output a semantic list of links.  See above for sample CSS.  Modify this to suit your design.
    */
   function output(){

      echo "<div id='breadcrumb'><ul><li>Click trail: </li>";

      foreach ($this->crumbs as $crumb){  

         if ($crumb['url'] != null){

            echo "<li> > <a href='".$crumb['url']."' title='".$crumb['label']."'>".$crumb['label']."</a></li> ";

         } else {

            echo "<li> > ".$crumb['label']."</li> ";

         }
      }

      echo "</ul></div>";
   }
}
?> 




source of this help
0

#2 User is online   rallport 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 3,814
  • Joined: 03-January 10
  • Reputation: 266
  • Gender:Male
  • Location:England, UK
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 10 March 2010 - 01:20 PM

You should a read of some php basics - the script you're downloading assumes you know hoe to use sessions.

Session_start() should be the first line of code on your page, before anything else - this would be the first thing I'd try anyway - as I assume the script you've downloaded works, it's your use of it that is flawed.

This highlights the need to understood the code you seem to have blindly downloaded, instead of simply copying and pasting from a 'scripts' site.

This is exactly what the majority of offshore web development companies tend to do - use premade script they've downloaded.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users