user2572818
user2572818

Reputation: 1

Cakephp breadcrumb

I am a Cakephp beginner

I am creating breadcrumbs from my website, I am not sure what is the difference between using HTML helper and Breadcrumb helper, Html helper seems easier to use, but it seems like I have to add each crumb to each page manually, please correct me if i am wrong.

When I was trying to use the Html helper, I put

 <?php echo $this->Html->getCrumbs(' > ', array( 'text' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index'), 'escape' => false)); ?>

in my index.ctp

then, i put

    <?php $this->Html->addCrumb('Add customer', 'Customers/add'); ?>

in add.ctp

the breadcrumb "Customer" appears on the index.ctp, but when i go to the add.ctp page, no breadcrumb is shown.

I tried putting

echo $this->Html->getCrumbs(' > ', 'Home');

in default.ctp, then the "Add customer" appears after the Home crumb

How can I make it so that, on the add.ctp , the breadcrumb shows like this: Customers > Add customer

Upvotes: 0

Views: 5043

Answers (1)

user221931
user221931

Reputation: 1852

You should take a better look at the documentation in the cookbook, usually it's all there.

Steps are:

  1. Create a place for cakePHP to display the breadcrubs in your layout template, not index.ctp using something like echo $this->Html->getCrumbs(' > ', 'Home');. You should find your default layout in View/Layout/default.ctp.
  2. Add a trail in each page with something like $this->Html->addCrumb('Add customer', 'Customers/add'); for View/Customers/add.ctp

This is all done by the HTML helper, there isn't any different (official) breadcrumb helper.

Upvotes: 2

Related Questions