Source Rally PHP Community Scripts .. Sign up .. Login
A class to create breadcrumbs :)
Access: Public      Tags: php, breadcrumb, class
Add to favourites       Subscribe comments       Copy code       Bookmark
<?php

//example
$breadcrumb = new breadcrumb();//declared globally

//call following where ever.
breadcrumb::add('Home','/');
breadcrumb::add('Category','/Cat');
breadcrumb::add('Product');
echo 
$breadcrumb->show();

//end of example

class breadcrumb
{
    var 
$content;
    var 
$links;
    var 
$visual;
    
    function 
breadcrumb()
    {
        
$this->content = array();
        
$this->links = array();
        
$this->visual "";
    }
        
    function 
add($content$tlink="")
    {
        if(!
$this instanceof breadcrumb)
        {
            global 
$breadcrumb;
            
$breadcrumb->add($content,$tlink);
            return 
true;
        }
        
$this->links[]=$tlink;
        
$this->content[]=$content;
    }
    
    
/*
    Vis objectet
    */
    
function show()
    {
        if(!
$this instanceof breadcrumb)
        {
            global 
$breadcrumb;
            return 
$breadcrumb->show($content,$tlink);
        }
        
$seperator " <span style=\"font-size:14px;font-weight:bold;\">&gt;&gt;</span> ";
        for(
$i=0;$i<count($this->content);$i++)
        {
            if(
$i!=(count($this->content)-1))
            {
                
$this->visual .= "<a href=\"".$this->links[$i]."\" title=\"".$this->content[$i]."\">".$this->content[$i]."</a>";
            }
            else
            {
                
$this->visual .= $this->content[$i];
            }
            if(
$i!=(count($this->content)-1))
            {
                
$this->visual .= $seperator;
            }
        }
        return 
$this->visual;
    }
    
    function 
is()
    {
        global 
$breadcrumb;
        return 
count($breadcrumb->links)>1;
    }
}
?>
Add to favourites       Subscribe comments       Copy code       Bookmark
Sign up to add your own comment here!

Shared by:

regin

Mail user Add to friends
All user contributed content is available under the unless specified otherwise.
Remaining copyrights Regin Gaarsmand 2006-2008
About www.SourceRally.net