nobuti / Codeigniter-breadcrumbs

Small breadcrumb library for CodeIgniter
70 stars 68 forks source link

How to add breadcrumbs? #6

Closed KasheenaTTV closed 9 years ago

KasheenaTTV commented 9 years ago

I'm newer to PhP, I have the library set up and I'd like to set my breadcrumbs but I can't figure out how. :c

I'm using codeigniter3.0

I don't know how to properly utilize the following:

// add breadcrumbs $this->breadcrumbs->push('Section', '/section'); // $this->breadcrumbs->push('Section', site_url('section') ); $this->breadcrumbs->push('Page', '/section/page'); // $this->breadcrumbs->push('Page', site_url('section/page') );

// unshift crumb $this->breadcrumbs->unshift('Home', '/'); // $this->breadcrumbs->unshift('Home', site_url('') );

// output $this->breadcrumbs->show();


Where do I put the adding of breadcrumbs? x.x

nobuti commented 9 years ago

Hi @MirandaR, basically you have to drop those files in those folders of your app installation. Then follow the instructions to load the library properly. You can get more information about libraries here: https://ellislab.com/codeigniter/user-guide/general/creating_libraries.html

KasheenaTTV commented 9 years ago

Yes, I get all that......... The libraries are installed and I'm trying to call it to my view page and it's not giving me any results. I also don't know how to add what page corresponds to what breadcrumb.

nobuti commented 9 years ago

@MirandaR try this, in your controller or in the autoload file, load the library:

$this->load->library('breadcrumbs');

Then before render the view, you can build the breadcrumb, usually in a method controller:

$this->breadcrumbs->push('Home', '/');
$this->breadcrumbs->push('Section', site_url('section') );
$this->breadcrumbs->push('Page', site_url('section/page') );

Then you can render the breadcrumb in the view:

$this->breadcrumbs->show();
KasheenaTTV commented 9 years ago

I'm getting the following error.

Fatal error: Call to undefined function site_url() in /home/mirandadev/yvette.caedon.net/application/libraries/Breadcrumbs.php on line 59
nobuti commented 9 years ago

It's a helper, I guess you need to load first too, take a look https://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

El 23/06/2015, a las 20:38, MirandaR notifications@github.com escribió:

I'm getting the following error.

Fatal error: Call to undefined function site_url() in /home/mirandadev/yvette.caedon.net/application/libraries/Breadcrumbs.php on line 59 — Reply to this email directly or view it on GitHub.

nkumar-meticulosity commented 6 years ago

I am unable to show more then one link with the same href.

example: $this->breadcrumbs->push('Section', '/section'); $this->breadcrumbs->push('Section1', '/section');

Can you suggest me the solution ?

nkumar-meticulosity commented 6 years ago

@nobuti I need to show 2 link with tha same href and this code is working for only one.

nobuti commented 6 years ago

@nkumar-meticulosity sorry, but I don't longer maintain this repo. You can't do that without changing the code to support that scenario. Open a PR if you find a better solution.