Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:38:54+00:00 2026-05-27T06:38:54+00:00

How can I build navigation menu from categories and sub categories, like this: http://mysite/categories/view/1/2

  • 0

How can I build navigation menu from categories and sub categories, like this:

http://mysite/categories/view/1/2

I tried menu builder 1.01 but it only works for acl users.
I also read this tutorial, but it was not helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:38:55+00:00Added an answer on May 27, 2026 at 6:38 am

    Your first link doesn’t work.

    Frankly, I’m not even sure I understand what you’re trying to do. The second link you supplied – I admit I only looked at the first code snippet – doesn’t use a database table. If you want your menu to be dynamic, as in based off controller actions, that makes sense. If you want it to be “dynamic” as in having dynamic control over menu items that you want to be able to have CRUD access to (you do know what CRUD stands for, right?), that’s a different (really really simple) story.

    This is the most basic, bare-bones example imaginable. I literally slapped this together in fifteen minutes in my sandbox Cake 1.3.12 installation. I am pretty sure I got all the names changed for Cake 2 conventions, however some tweaking may be necessary. I tried to pare it down to the absolute basics and keep the code as clear as possible. Build it out as it suits you. Refer to the cookbook and remember to follow Cake convention at all times.

    1. Create a table with a name like menus.
    2. Create a model called menu.php.
    3. Create a MenusController.php.
    4. Create the /Views/Menus directory, and /views/Elements/Menus.

      CREATE TABLE menus (
      id int(11) unsigned NOT NULL auto_increment,
      name varchar(255) NOT NULL default ”,
      controller varchar(255) NOT NULL,
      action varchar(255) NOT NULL,
      created datetime NOT NULL,
      modified datetime default NULL,
      PRIMARY KEY (id)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    Model code – Menu.php:

    <?
    class Menu extends AppModel {
        var $name = 'Menu';
    }
    

    Controller code – MenusController.php:

    <?
    class MenusController extends AppController {
    var $name = 'Menus';
    
    function index() {
        if (isset($this->params['requested']) && $this->params['requested'] == true) {
            $menus = $this->Menu->find('all');
            return $menus;
        } else {
            $this->set('menus', $this->Menu->find('all'));
        }
    }
    
    function add() {
        if (!empty($this->data)) {
            if ($this->Menu->save($this->data)) {
                $this->Session->setFlash(__('The menu item has been saved', true));
            }
        }
    }
    
        // Build out additional CRUD functionality, 
        // for example edit / view / delete, as desired.
    
    }
    

    Every MenusController action requires an [action name].ctp file in /view/menus/.

    So create /views/menus/index.ctp and /views/menus/add.ctp. What you put in /views/menus/index.ctp isn’t even terribly important, and /views/menus/add.ctp is the form you will use to add new menu items as desired:

    <div class="menus form">
    <?php echo $this->Form->create('Menu');?>
        <fieldset>
            <legend><?php __('Add Menu Item'); ?></legend>
    <?php
        echo $this->Form->input('name');
        echo $this->Form->input('controller');
        echo $this->Form->input('action');
    ?>
        </fieldset>
        <?php echo $this->Form->end(__('Submit', true));?>
    </div> 
    

    Now, create /views/elements/menus/main.ctp:

    <ul class="header main-menu">
    <? if (!isset($menus) || empty($menus)) :
            $menus = $this->requestAction('/menus/index');
        endif; 
        foreach($menus as $menu) : 
    ?>
        <li>
        <?="<a href='".DS.$menu['Menu']['controller'].DS.$menu['Menu']['action']."'>".$menu['Menu']['name']."</a>"; ?>
        </li>
    <? endforeach; ?>
    </ul>
    

    Finally, place the element in the layout so it appears on every page, regardless of view. If you are using the default cake layout, that means you should edit /views/layouts/default.ctp. You probably want to put this item someplace sensible, such as the <div id="header"> element. Insert the element() call as follows:

    <div id="header">
        <!-- whatever markup, code, etc. you may have in the header is fine. -->
        <?= $this->element('menus/main'); ?>
    </div>
    <!-- ...the rest of your layout continues... -->
    

    It may be necessary to add styling to your element to make it readable. Add styling to whatever stylesheet/s you may have (the default is cake.generic.css) as desired.

    HTH. The cookbook is your friend.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I build a PHP navigation menu that highlights the current page using
I have an object that can build itself from an XML string, and write
Is there a way I can build a bitmap strictly from RGB values for
I would like to have a vertical navigation menu compatibbel with jQuery UI ThemeRoller.
I am building a system in which the user can build thre own navigation
I'd like to only get the worddpress navigation (header, navigation menu, footer) so I
I have a Drupal 7 CMS with a Navigation build with nice_menus ( http://drupal.org/project/nice_menus
I am trying to build a navigation menu using nested lists, however whenever I
I'm trying to build a front-end and back-end navigation menu. I want to display
I understood changing corner and disable navigation bar. but i need to build through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.