Welcome Guest, Not a member yet? Register   Sign In
Custom Breadcrumbs
#13

[eluser]iive[/eluser]
The solution that I am doing is :

Create a Breadcrumb class and a BreadcrumbNode class. Breadcrumb class will have a function called addNode() which accept BreadcrumbNode and a function called build() to build out the whole breadcrumb.

I use a config file to define all the static page in an array and then pass the whole array into Breadcrumb class to build the tree.


BreadcrumbNode take arguements as:
BreadcrumbNode($level, $parent_id, $node_id, $indentifier, $href, $label );

It looks something similiar to:
Code:
$node_array = array();
$node_array[] = new BreadcrumbNode(0,NULL,0,"home", "home", "Home");
$node_array[] = new BreadcrumbNode(1,0,1,"games", "game", "Games");
$node_array[] = new BreadcrumbNode(1,0,2,"member_page", "user", "My Account");

Inside controller,
Code:
class Game extends Controller {

    function Game()
    {
       parent::Controller();
       $this->load->library('breadcrumb');
    }
    
    function index()
    {
       // Will produce Home >> Games
       echo $this->breadcrumb->render("games"));
    }

    function play(){
       //Get game name dynamically from URI
       $game_name = $this->uri->segment(3);
            
       // Add new BreadcrumbNode dynamically by specify the new level and parent id
       // set the third arguement to null so that Breadcrumb class can generate
       // next increment id
       $this->breadcrumb->addNode(new BreadcrumbNode(2,1,null,"games-play","game/play/".$game_name, $game_name));

       // Generate the breadcrumb
       // will produce Home >> Games >> Game Name
       echo $this->breadcrumb->render("games-play");
            
    }
}

I hope you get what I tried to mean. I am not sure whether this is a good way to work with breadcrumb. I have searched through the forums, but I couldn't get a good solution for this. So I come out these 2 classes to accomplish my task.


Messages In This Thread
Custom Breadcrumbs - by El Forum - 11-21-2007, 09:38 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 10:22 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 10:26 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 10:40 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 10:55 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 11:07 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 11:20 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 11:30 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 11:48 AM
Custom Breadcrumbs - by El Forum - 11-21-2007, 11:54 AM
Custom Breadcrumbs - by El Forum - 11-23-2007, 08:41 AM
Custom Breadcrumbs - by El Forum - 11-23-2007, 09:06 AM
Custom Breadcrumbs - by El Forum - 11-23-2007, 11:13 AM
Custom Breadcrumbs - by El Forum - 11-23-2007, 11:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB