To do this in Cakephp, we just need to add few lines in the design template where one like to show the breadcrumb:
Explanation:
$html->getCrumbs : It gets all the addCrumbs being added. The parameters are the “separator” ( >) which can be replaced by anything of our wish and the last parameter is the one which act as the “Home” page. In the above example it is Home itself.
Need to mention one thing, that if we do not mention any addCrumb in any of the pages and if we mention only the getCrumb, then the Breadcrumb will show up as Home > .
$html->addCrumb : In the above example , the breadcrumb menu will add ‘Menu‘ whenever the user goes to the ‘/menus’ controller. We can add as much breadcrumbs we like, only the addCrumb is need to be called. For example in the above code, the breadcrumb will add ‘SubMenu‘ whenever the user goes to ‘/menus/submenu’ (/controller/method).
To add CSS property we can place the code inside a div or span and use the id or class for specifying style.
For example if we want the last Breadcrumb menu item to be underlined, then we can specify an array to its property and add class to it.[ $html->addCrumb(‘SubMenu’ , ‘/menus/submenu’ , array(‘class’ => ‘breadcrumblast’)); ]
Note:
We need not to worry about the location where one add the addCrumb call as it doesn’t matter. It just has to be somewhere in your view file. The navigation entries don’t have to belong to the same controller, so one can even combine different controllers and methods.