[CakePHP]How to create navigation with well thought out about current page

Using layout template is general at cakephp view. There is a global menu in layout template. If we show the selected global menu in each page even if it takes time a bit, it looks neat as the example below which I found at Google group.

$navLinks = array(
‘home’ => array(
‘title’ => ‘home’,
‘path’ => ‘/’,
‘services’ => array(
‘title’ => ‘our services’,
‘path’ => ‘/pages/services’,
‘contact’ => array(
‘title’ => ‘contact us’,
‘path’ => ‘/contacts’,
‘about’ => array(
‘title’ => ‘about us’,
‘path’ => ‘/pages/about’,

<ul id="global_nav">
<?php foreach ($navLinks as $key => $link) :

$class = null;
if (strpos($this->params[‘url’][‘url’], substr($link[‘path’], 1)) !== false) {
$class = array(‘class’ => ‘current’);

<li id="nav_<?=$key?>"><?=$html->link($link[‘title’], $link[‘path’], $class)?></li>
<?php endforeach; ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.