Welcome Guest, Not a member yet? Register   Sign In
DTE BreadCrumb Class
#21

[eluser]Mat-Moo[/eluser]
Ok was too good to be true, works great... except if you want to change to another item at the same level? So based on that I made a minor change for my needs
Code:
<?php  if (!defined('APPPATH')) exit('No direct script access allowed');

session_start();

/*
* @Author: Dean Ericson
* @Email: [email protected]
*
* altered by Matthew Augier to use as levels
*/

final class BreadCrumb{
    private $title;
    private $url;
    private $level;

    /*
     * No need to set anything up.  I autoload it and
     * let the setters mutate the properties through the
     * setBreadCrumb function
     */
    function BreadCrumb(){}

    /*
     * Takes an array which represents this class (BreadCrumb)
     * as a parameter. Sets the class through it mutators,
     * then sets itself within the BreadCrumbList Object.
     */
    function setBreadCrumb($bcObjArr){
        $this->title=$bcObjArr['title'];
        $this->url=$bcObjArr['url'];
        $this->level=$bcObjArr['level'];

        $CI =& get_Instance();
        $CI->breadcrumblist->add($this);
        $_SESSION['breadCrumbList'] = $CI->breadcrumblist->getBreadCrumbs();
    }

    function getTitle(){
        return $this->title;
    }
    function setTitle($t){
        $this->title=$t;
    }
    function getUrl(){
        return $this->url;
    }
    function setUrl($u){
        $this->url=$u;
    }
    function getlevel(){
        return $this->level;
    }
    function setlevel($u){
        $this->level=$u;
    }
}
?>

and

(only posted changed section)
Code:
function add($bc){
            if ($bc->getlevel()==0) {
                $this->reset();
            }
            else
            {
                if (count($this->breadCrumbs)>=$bc->getlevel()+1)
                {
                    array_splice($this->breadCrumbs, $bc->getlevel());
                }
            }
            $this->breadCrumbs[] = $bc;
            $_SESSION['breadCrumbList']=$this->breadCrumbs;
    }

So this works the same except instead of root true/false you send a level starting from 0 - I'm not sugesting that this is for everyone, but this is the way I needed it to work. Stops my breadcrumbs running out of control, but depends what you need Smile
#22

[eluser]naren_nag[/eluser]
Very good looking library - found it just as I was about to sit down and write me own Smile Have downloaded, will give it a whirl asap Smile

cheers,

naren
#23

[eluser]ericsodt[/eluser]
@mat-moo, glad it worked for you! Do you have a demo site, I'd like to see how it looks

Thx
#24

[eluser]mjsilva[/eluser]
Hi there,

thanks for this library, really helpfull.

Just a bug/typo in config you have breadcrumbDelimeter and in library you have breadcrumbDelimiter (notice the I/E)

cheers
#25

[eluser]Constantin Iliescu[/eluser]
Hello, world! Big Grin
I put this library in my project but I came to this: I am on a view and I submit some form data to a method from a different controller. Any ideas how I could "restore" the url where I was when I submitted my form data, so that the breadcrumb remains the same?
Thanks!
#26

[eluser]ericsodt[/eluser]
Pull from the this Object.

IE:
Code:
get_Instance()->breadcrumblist

This code above will give you the current BreadCrumbList object that contains all your BreadCrumb Objects.


Please refer back to the original post for more examples on how to use this library




[quote author="Constantin Iliescu" date="1261444871"]Hello, world! Big Grin
I put this library in my project but I came to this: I am on a view and I submit some form data to a method from a different controller. Any ideas how I could "restore" the url where I was when I submitted my form data, so that the breadcrumb remains the same?
Thanks![/quote]
#27

[eluser]Constantin Iliescu[/eluser]
Thanks, ericsodt!
#28

[eluser]bhakti.thakkar[/eluser]
Hello,
I have installed the DTE BreadCrumbs files as per the instructions. But i am getting an error. I am also using the same example of Home controller to run a test. But its failing. I have already posted this problem yesterday, but still no replies on this. The thread is found here : http://ellislab.com/forums/viewthread/151853/
Hope i am not violating any forums rules by opening this discussion here again. Apologies for the same. But i am in desperate need to make this running.

Error is as below :

Fatal error: BreadCrumbList::display() [function.BreadCrumbList-display]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "BreadCrumb" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /var/www/CUI_CI/system/application/libraries/Breadcrumblist.php on line 59

Thanks
#29

[eluser]ericsodt[/eluser]
Sounds like the BreadCrumbList object is not being auto-loaded correctly. What version of CI are you using, example code or demo page for me to view?


[quote author="bhakti.thakkar" date="1270899908"]Hello,
I have installed the DTE BreadCrumbs files as per the instructions. But i am getting an error. I am also using the same example of Home controller to run a test. But its failing. I have already posted this problem yesterday, but still no replies on this. The thread is found here : http://ellislab.com/forums/viewthread/151853/
Hope i am not violating any forums rules by opening this discussion here again. Apologies for the same. But i am in desperate need to make this running.

Error is as below :

Fatal error: BreadCrumbList::display() [function.BreadCrumbList-display]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "BreadCrumb" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /var/www/CUI_CI/system/application/libraries/Breadcrumblist.php on line 59

Thanks[/quote]
#30

[eluser]Bazze[/eluser]
Hmm.. works great as long as you click your way thru on the site, but if you for example click a link which leads to a page which should be 'Home > Sub level 1 > Sub level 2 > Sub level 3' it just becomes Sub level 3.




Theme © iAndrew 2016 - Forum software by © MyBB