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 7665541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:35:43+00:00 2026-05-31T14:35:43+00:00

I’m trying to build a front-end and back-end navigation menu. I want to display

  • 0

I’m trying to build a front-end and back-end navigation menu.
I want to display only the back-end menu in the back-end and visa versa.

It’s working correctly, when i set the ACL off. But, when i put in on, the menu’s are gone.
Does anybody know, how i can solve this?

This is my code:

EDIT:

I changed the navigation.xml and now, it’s almost working correctly.

The top menu items are working when i allow the controller.
But, when i only want to allow a specific action inside a controller the whole submenu is displaying instead of the allowed action.

I hope, you understanding the problem. I’m sorry, my English isn’t that well.

in bootstrap.php

protected function _initNavigation()
{
    $this->bootstrap('layout');
    $layout = $this->getResource('layout');
    $view = $layout->getView(); 

    $identity = $this->_auth->getStorage()->read();
    if($identity)
    {
        $roles = new Application_Model_Auth_Roles();
        $role = $roles->getRoles($identity->role);
    } else {
        $role[0]['role'] = 'Guest';
    }

    $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
    $container = new Zend_Navigation($config);

    $view->navigation($container)
                    ->setAcl($this->_acl)
                    ->setRole($role[0]['role']);

    // default menu         
    $view->nav = $view->navigation()->findOneByLabel('mainnav');

}

CmsControllor.php

class CmsController extends Zend_Controller_Action
{
    public function init()
    {

        //// BUILD MENU
        $this->view->nav = $this->view->navigation()->findOneByLabel('cms');

        ...

view:

<?= $this->navigation()->menu()->renderMenu($this->nav); ?>

navigation.xml

    <config>
  <nav>
  <mainnav>
     <label>mainnav</label>
     <module>default</module>
     <pages>
            <home>
                <label>Home</label>
                <controller>index</controller>
                <resource>index</resource>
            </home>

            <page1>
                <label>De Esdoorn</label> 
                <controller>page1</controller>
                <resource>deesdoorn</resource>

            </page1>

            <page2>
                <label>page2</label>
                <controller>page2</controller>

                <pages>
                    <algemeen>
                        <label>Algemeen</label>
                        <controller>page2</controller>
                        <action>index</action>
                        <resource>page2</resource>
                        <privileges>index</privileges>
                    </algemeen>
                    <biedt>
                        <label>page2 biedt</label>
                        <controller>page2</controller>
                        <action>biedt</action>  
                        <privileges>biedt</privileges>

                    </biedt>
                    <zorg>
                        <label>Zorg</label>
                        <controller>page2</controller>
                        <action>zorg</action>  
                        <privileges>zorg</privileges> 
                    </zorg>
                    <download>
                        <label>Download onze folder</label>
                        <uri>folder url</uri>
                        <target>_blank</target>
                    </download>

                </pages>        
            </page2>

            <organisatie>
                <label>Onze organisatie</label>
                <controller>organisatie</controller>

                <pages>
                    <algemeen>
                        <label>Algemeen</label>
                        <controller>organisatie</controller>
                        <resource>organisatie</resource> 
                        <privileges>index</privileges> 
                    </algemeen>
                    <missieenvisie>
                        <label>Missie en visie</label>
                        <controller>organisatie</controller>
                        <action>missieenvisie</action> 
                        <privileges>missieenvisie</privileges> 

                    </missieenvisie>
                    <dienstverlening>
                        <label>Dienstverlening</label>
                        <controller>organisatie</controller>
                        <action>dienstverlening</action> 
                        <privileges>dienstverlening</privileges> 
                    </dienstverlening>
                    <kosten>
                        <label>Kosten</label>
                        <controller>organisatie</controller>
                        <action>kosten</action>
                        <privileges>kosten</privileges> 
                    </kosten>

                    <nieuws>
                        <label>Nieuws</label>
                        <controller>organisatie</controller>
                        <action>nieuws</action>
                        <privileges>nieuws</privileges> 
                    </nieuws>





                </pages>        
            </organisatie>

            <contact>
                <label>Contact</label> 
                <controller>contact</controller>
                <resource>contact</resource>
            </contact>
     </pages>
  </mainnav>

  <cms>
     <label>cms</label>
     <module>default</module>
     <pages>
            <dashboard>
                <label>Dashboard</label>
                <controller>cms</controller>
                <action>dashboard</action>
                <resource>cms</resource>
                <privileges>nieuws</privileges>
            </dashboard>

            <nieuwsbeheren>
                <label>Beheer uw nieuws</label> 
                <controller>cms</controller>
                <action>managenews</action>
                <resource>cms</resource>
            </nieuwsbeheren>

            <fotoalbum>
                <label>Foto album</label>
                <controller>fotoalbum</controller>
                <pages>
                    <index>
                        <label>Album overzicht</label>
                        <controller>fotoalbum</controller>
                         <privileges>index</privileges>
                    </index>
                    <add>
                        <label>+ Album toevoegen</label>
                        <controller>fotoalbum</controller>
                        <action>add</action>
                        <resource>fotoalbum</resource>
                        <privileges>add</privileges>
                    </add>
                    <clientoverview>
                        <label>Bewoner overzicht</label>
                        <controller>fotoalbum</controller>
                        <action>clientoverview</action>
                        <privileges>clientoverview</privileges>
                    </clientoverview>

                    <useroverview>
                        <label>Naaste overzicht</label>
                        <controller>fotoalbum</controller>
                        <action>useroverview</action>
                        <privileges>useroverview</privileges>
                    </useroverview>


                </pages>        
            </fotoalbum>
            <settings>
                <label>Instellingen</label>
                <controller>cms</controller>
                <action>settings</action>
                <resource>cms</resource>
                <privilege>settings</privilege>
            </settings>
            <logout>
                <label>Uitloggen</label>
                <controller>cms</controller>
                <action>logout</action>
                <resource>cms</resource>
                <privilege>logout</privilege>
            </logout>
     </pages>
  </cms>
 </nav>
 </config>

My ACL plugin:

class My_Plugins_CheckAccess extends Zend_Controller_Plugin_Abstract
{

private $_acl = NULL;
private $_auth = NULL;

public function __construct(Zend_Acl $acl, Zend_Auth $auth)
{
    $this->_acl = $acl;
    $this->_auth = $auth;
}

public function preDispatch(Zend_Controller_Request_Abstract $request){

    $controller = $request->getControllerName();
    $action     = $request->getActionName();

    $identity = $this->_auth->getStorage()->read();
    if($identity)
    {
        $roles = new Application_Model_Auth_Roles();
        $role = $roles->getRoles($identity->role);
    } else {
        $role[0]['role'] = 'Guest';
    }

    if(!$this->_acl->isAllowed($role[0]['role'],$controller,$action))
    {
        $request->setControllername('login')->setActionName('index');
    } else
    {

    }

}

My Rules file (the rules are from the database)

class Application_Model_Auth_CmsAcl extends Zend_Acl {

public function __construct(){

    $logic = new Application_Model_Auth_Logic();

    $pages  = new Application_Model_Auth_Pages();
    $pagecollection = $pages->getPages();
    $pagelist = $logic->listPages($pagecollection);

    $roles  = new Application_Model_Auth_Roles();
    $rolecollection = $roles->getRoles();

    $resources  = new Application_Model_Auth_Resources();
    $resourcecollection = $resources->getResource();

    foreach($pagelist as $controller)
    {

        if($controller['controllerBase'] == 1): 
            $this->add( new Zend_Acl_Resource($controller['controller']));
        endif; 

    }

    foreach($rolecollection as $role)
    {
        $this->addRole( new Zend_Acl_Role($role['role']));
    }

    foreach($resourcecollection as $resource)
    {
        $roleName = $roles->getRoles($resource['roleID']);
        $pageName = $pages->getPages($resource['pageID']);
        if($pageName[0]['action'] != ''){
            $this->allow($roleName[0]['role'],$pageName[0]['controller'],$pageName[0]['action']);
        } else {$this->allow($roleName[0]['role'],$pageName[0]['controller']);}
    }

}

 }  

This is my first zend website. Please, correct me when i make mistakes.

  • 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-31T14:35:45+00:00Added an answer on May 31, 2026 at 2:35 pm

    Okay, i edited this rule in my rules file:

    $this->allow($roleName[0]['role'],$pageName[0]['controller'],$pageName[0]['action']);
    

    to

    $this->allow($roleName[0]['role'],$pageName[0]['controller'],array('index',$pageName[0]['action']));
    

    So I attached an array to my action where index is included.
    This means it’s working. but it will always shows the index page when i only want to allow a certain action.

    I found out that this is, of course, quite logically, since the top menu item is triggered only by the entire controller or the index action.

    For this, you must attach this code to the top menu item:

    <resource>page2</resource>
    <privilege>index</privilege>
    

    A solution would be a custom menu plugin that only triggers the top menu item when index or an other action inside the controller is allowed.

    Or does maybe someone knows, how the set multiple privileges to the top menu item?
    Something like this?:

    <page2>
                    <label>page2</label>
                    <controller>page2</controller>
                    <privilege>index</privilege>
                    <privilege>zorg</privilege>
                    <privilege>biedt</privilege>
    
                    <pages>
                        <algemeen>
                            <label>Algemeen</label>
                            <controller>page2</controller>
                            <action>index</action>
                            <resource>page2</resource>
                            <privilege>index</privilege>
                        </algemeen>
                        <biedt>
                            <label>page2 biedt</label>
                            <controller>page2</controller>
                            <action>biedt</action>  
                            <privilege>biedt</privilege>
    
                        </biedt>
                        <zorg>
                            <label>Zorg</label>
                            <controller>page2</controller>
                            <action>zorg</action>  
                            <privilege>zorg</privilege> 
                        </zorg>
                        <download>
                            <label>Download onze folder</label>
                            <uri>folder url</uri>
                            <target>_blank</target>
                        </download>
    
                    </pages>        
                </page2>
    

    So, when the privilege is OR index, OR biedt, OR Zorg -> show this top menu item.

    Another mistake I made, was typing

    <privileges> instead of <privilege>

    Thank you for the help.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
i want to parse a xhtml file and display in UITableView. what is the
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

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.