Dec 22 2008, 01:40 PM
I am using cake_18.104.22.16892-rc3 for my application.
I want to display top menu links in all pages(.ctp).
Then, how can i do this.
Dec 22 2008, 01:57 PM
you should creat a file 'default.ctp' in folder app/view/layout/
Dec 22 2008, 04:10 PM
You can use element to include your menu into default.ctp layout
Create file for example: menu.ctp with your menu links and place it into views -> element folder
then write [PHP] echo $this->element('menu');[/PHP] in your default.ctp layout
You can even cache your element menu
Check this out:http://book.cakephp.org/view/97/Elements
Dec 23 2008, 01:11 PM
Thanks for replying.
I am created element menu.ctp.
At there Suppose i write code:
|<?php e($html->link('Administrators', '/Admins/index'));?>|
<?php e($html->link('Section Management', '/Sections/index'));?>|
<?php e($html->link('UserType Management', '/UserTypes/index'));?>|
<?php e($html->link('Domain Management', '/Domains/index'));?>|
But currently this is static.
But i want to fetch them from database.
So where i should write code for that.
For example: for add.ctp i write code in add action of related controller.
So i can set view for add.ctp.
But for menu.ctp (element) from where i can set that view.
And also tell me $content_for_layout comes from where?
Thanks For Replying.
Again wait 4 reply.
Dec 23 2008, 02:35 PM
Just read cake book:PassingVariables into an Element
May 5 2009, 01:01 PM
thanks to all. i just follow the rules u all mentioned and solve my problems.
May 25 2009, 07:06 PM
the simplest way to create and element at
and called it
where you want to display on simple using
you can call a dynamic menu like left menu in element and render it in all project.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here