• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DTE BreadCrumb Class

#11
[eluser]ericsodt[/eluser]
[quote author="morozgrafix" date="1231921963"]Thank you for creating this class. I just added it to my project and it works great.
Sorry can't give you URL for the site since this is intranet portal site.

One thing to add (and I haven't played much with DTE BreadCrumb Class yet) is ability to specify configurable option for breadcrumb delimiter.

For example one would like to use ">" as delimiter for some parts of the project and then use "»" or "→" somewhere else.

I've hardcoded it for my project to this on line 34 of Breadcrumb.php for now:

Code:
$CI->breadcrumblist->setDelimeter(' » ');

I've checked and URL helper is not loaded by default in CI 1.7. My vanilla autoload.php shows this:

Code:
/*
| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
|    $autoload['helper'] = array('url', 'file');
*/

$autoload['helper'] = array();
[/quote]

Well I stand corrected then... I apologize.

Yes, there is a way to set the delimiter. Since I created the BreadCrumbList as a POPO (Plain old PHP Object), you can set any of the BreadCrumbList's properties.

BreadCrumbList.php file
Code:
function setDelimeter($d){
    $this->delimeter='<span class="delimeter" >'.$d.'</span>';
}

Code has been updated and the new version released which takes care of this. You now just have to set it within the config file and the library does the rest.

#12
[eluser]morozgrafix[/eluser]
Hello Dean,

Thank you for quick reply. I think you missing session_start(); call on line 2 of Breadcrumb.php in your latest version it should be this:

Code:
&lt;?php  if (!defined('APPPATH')) exit('No direct script access allowed');
session_start();

/*
* @Author: Dean Ericson
* @Email: mail@deanericson.com
*
*/
//...

I also was looking around to be able to change delimiter within same project. For example to be able to specify individual delimiters for different pages. I have modified setBreadCrumb method in Breadcrumb.php (I know this may not be most efficient solution, but it works for me)

Code:
//...
function setBreadCrumb($bcObjArr){
    $this->title=$bcObjArr['title'];
    $this->url=$bcObjArr['url'];
    $this->isRoot=$bcObjArr['isRoot'];
    if(isset($bcObjArr['delimiter'])){
        $this->delimiter=$bcObjArr['delimiter'];    
    }
    
    $CI =& get_Instance();
    $CI->breadcrumblist->add($this);
    if(isset($this->delimiter)){
        $CI->breadcrumblist->setDelimiter($this->delimiter);
    }
    $_SESSION['breadCrumbList'] = $CI->breadcrumblist->getBreadCrumbs();        
}
//...

Now, delimiter could be specified within $bc array in my controller like this:
Code:
//...
$bc = array (
    'title' => 'Latest Reports',
    'url' => '/qareports',
    'delimiter' => ' any_new_delimiter ',
    'isRoot' => true
);
//...

With this change delimiter could be set from $bc array, if not set here it would be picked up from config.php (your latest change in 1.6 release) and then if not found in config.php would be defaulted to hardcoded setting.

Oh, and one more thing, I've noticed that word delimiter was misspelled in your code, it was spelled as "delimeter" - I ended up correcting spelling throughout the code.

Once again thank you for sharing your code and your quick replies.

Sergey.

#13
[eluser]ericsodt[/eluser]
[quote author="morozgrafix" date="1231984491"]Hello Dean,

Thank you for quick reply. I think you missing session_start(); call on line 2 of Breadcrumb.php in your latest version it should be this:

Code:
&lt;?php  if (!defined('APPPATH')) exit('No direct script access allowed');
session_start();

/*
* @Author: Dean Ericson
* @Email: mail@deanericson.com
*
*/
//...

I also was looking around to be able to change delimiter within same project. For example to be able to specify individual delimiters for different pages. I have modified setBreadCrumb method in Breadcrumb.php (I know this may not be most efficient solution, but it works for me)

Code:
//...
function setBreadCrumb($bcObjArr){
    $this->title=$bcObjArr['title'];
    $this->url=$bcObjArr['url'];
    $this->isRoot=$bcObjArr['isRoot'];
    if(isset($bcObjArr['delimiter'])){
        $this->delimiter=$bcObjArr['delimiter'];    
    }
    
    $CI =& get_Instance();
    $CI->breadcrumblist->add($this);
    if(isset($this->delimiter)){
        $CI->breadcrumblist->setDelimiter($this->delimiter);
    }
    $_SESSION['breadCrumbList'] = $CI->breadcrumblist->getBreadCrumbs();        
}
//...

Now, delimiter could be specified within $bc array in my controller like this:
Code:
//...
$bc = array (
    'title' => 'Latest Reports',
    'url' => '/qareports',
    'delimiter' => ' any_new_delimiter ',
    'isRoot' => true
);
//...

With this change delimiter could be set from $bc array, if not set here it would be picked up from config.php (your latest change in 1.6 release) and then if not found in config.php would be defaulted to hardcoded setting.

Oh, and one more thing, I've noticed that word delimiter was misspelled in your code, it was spelled as "delimeter" - I ended up correcting spelling throughout the code.

Once again thank you for sharing your code and your quick replies.

Sergey.[/quote]

Sergey,

I realized I spelled it wrong on version 1.5, but didn't have the time to go through and fix it (being lazy really). I will make the changes you have brought to light. Yes I am missing the session_start() at the top of the page... I made the update quickly last night and left that out... no excuse really. I will also incorporate your changes into the next release (1.7) which I should be able to get out tonight or tomorrow depending on my work schedule.

Thank you for your feedback!!

#14
[eluser]morozgrafix[/eluser]
Sounds good,
My solution may not be most elegant, but I think you get the idea and what I was trying to do with it. I just realized one more thing. With current directory structure in download zip, someone may accidentally overwrite their config.php file with one supplied from the zip. Maybe it would be a good idea to add it to documentation or rename it somehow.

Thanks.

#15
[eluser]ericsodt[/eluser]
[quote author="morozgrafix" date="1231985566"]Sounds good,
My solution may not be most elegant, but I think you get the idea and what I was trying to do with it. I just realized one more thing. With current directory structure in download zip, someone may accidentally overwrite their config.php file with one supplied from the zip. Maybe it would be a good idea to add it to documentation or rename it somehow.

Thanks.[/quote]

Good point, I tried to make note of it at the very top of this thread, but I guess it is better to spell it out so that the entire config file does not get over written.

Thanks again

#16
[eluser]ericsodt[/eluser]

I uploaded a new version, 1.7 fixing the session_start() problem. I did not however make the changes to add a delimiter property to the BreadCrumb Object. I made this library for my application and do not think I would ever want to change the delimiter based upon the action. For me, a delimiter should be an application wide property to keep the application in uniform. If anyone feels like they would like to, please see the posts above...

#17
[eluser]Unknown[/eluser]
Great library, ericsodt!

Works very well for me, once I realized it was a mistake to feed dynamic page titles to the breadcrumbs on a page I had which used an alphabetical (A | B | C | D...) navigation feature and had titles like "Browsing 'A'." Those breadcrumbs became a little longish. Smile Easy enough to fix, though, by using a static title that was not linked up to the page arguments.

Many thanks!

mlsamuelson

#18
[eluser]shahriat[/eluser]
Hi, i have this url http://localhost/HMDesignCMS/album/createnew when i use this breadcrumb library then my segments come like this Album >> Createnew But i want also this segment(http://localhost/HMDesignCMS) named Home. Is it possible using this library?


Thanx

#19
[eluser]ericsodt[/eluser]
[quote author="shahriat" date="1237154793"]Hi, i have this url http://localhost/HMDesignCMS/album/createnew when i use this breadcrumb library then my segments come like this Album >> Createnew But i want also this segment(http://localhost/HMDesignCMS) named Home. Is it possible using this library?


Thanx[/quote]

I am sorry, I do not fully understand your question. The library is not based off of URI segments. Your Action class dictates the breadcrumb. Please visit my breadcrumb demo page for a better idea of what I am talking about.

Please provide a better explanation and if possible a link to your development site so I can see what you're talking about.

Thanks

#20
[eluser]Mat-Moo[/eluser]
Cracking little library, works like a charm Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.