1

I am working on CakePHP 2.7. I have to show some static menu on every page. Since, the menu contains lot of sub menus, I want to keep them in a separate file navigation.ctp and show them on default.ctp

I tried extend and elements but none of them give expected result.

Note : This is not dynamic menu and I am not fetching them from database.

Anuj TBE
  • 9,198
  • 27
  • 136
  • 285

1 Answers1

2

Place your navigation.ctp inside app/View/Elements/

Then, inside your default.ctp, include the element as follows:

<?= $this->element('navigation'); ?>

Note that if you need any variables within the element, you may need to pass them through inside an array as a second parameter, such as:

<?= $this->element('navigation', array(
    "varible_name" => "variable_value"
    )); ?>
Warren Sergent
  • 2,542
  • 4
  • 36
  • 42