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

The Archive Base Latest Questions

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

[See update at the end] I’m working with Zend framework, in PHP and I

  • 0

[See update at the end]

I’m working with Zend framework, in PHP and I have some difficulties with Zend Navigation. It’s my first question here, so if something’s wrong with it, just tell me and I’ll correct it.

I have a menu looking like this in my application

Home 
Login
Logout
Member's Page

I have a navigation xml file containing my menu.

<nav>
 <home>
    <label>Home</label>
    <uri>/</uri>
 </home>
 <login>
    <label>Login</label>
    <uri>/index/login</uri>
 </login>
 <logout>
    <label>Logout</label>
    <uri>/index/logout</uri>
 </logout>
 <member>
    <label>Member's Page</label>
    <uri>/index/member</uri>
 </member>
</nav>

Also a menu.phtml containing this

<div class="top-level">
<?php
foreach ($this->container as $page) {
    if ($page->isVisible()) {
        if ($page->isActive(true)) {
            if ($page->isActive(false)
                )$page->setClass("active");
            else
                $page->setClass("open");
            echo $this->navigation()->menu()->htmlify($page);
//... the same continue for the 3 menu level

Finally, in my layout.phtml, I have this to render the menu

<?php
      $partial = array('menu.phtml', 'default');
      $this->navigation()->menu()->setPartial($partial);
      echo $this->navigation()->menu()->render();
?>

For now, my menu works good, but I can’t have Login and Logout always displayed in my menu. So, what I need to do, is to hide Login when I’m logged in, and to hide Logout when I’m logged out. It looked pretty simple when I started, and it still does, but I can’t make it work. I don’t know how and if I can hide and show item depending on logged users. I really need to make it work, because I will need to hide/display other items in the future.

So is there a way of doing that ?

Thanks !

EDIT :

I’m currently not using Zend::Auth or Zend_ACL for roles and authorization. If I want to know if the user is logged in or not, I have a token in the session that is valid only when the user is logged in. I’d like my menu to work without changing that if it’s possible.

UPDATE :

I had it working in another way than those suggested. I’m really not sure it’s a clean way, but it’s doing the job for now. So now, my xml navigation file look like

<menuAnonymous>
     <home>
     <label>Login</label>
        <uri>/login</uri>
     </home>
    </menuAnonymous>
    <menuLogged>
     <home>
        <label>Logout</label>
        <uri>/Logout</uri>
     </home>
    </menuLogged>

I initialize both in my bootstrap like this.

$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'menuNotLogged');    
$container = new Zend_Navigation($config);
Zend_Registry::set('main',$container);

And then, in my layout, I look at my token and display the menu depending on that.

if ($tokenValid) {
     echo $this->navigation()->menu()->render(Zend_Registry::get('main')); 
} else {
     echo $this->navigation()->menu()->render(Zend_Registry::get('logged'));
}

So it’s working like I want now, but I still want to do it cleaner, so if you have any suggestions to help me … thank you !

  • 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-26T06:38:10+00:00Added an answer on May 26, 2026 at 6:38 am

    I updated my question with the solution I used, maybe I’ll find a better way to do it later but for now this is it. I didn’t find the solution here, that’s why I’m answering my own question. Thanks for your help !

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

Sidebar

Related Questions

Update: See the bottom of this question for a C# workaround. Hi there, Consider
Update: After some more reading I see that this problem is totally general, you
Update: Solved, with code I got it working, see my answer below for the
I see the answer here is no, but wondered if there is any update
Update: this question, including the title, was rephrased, see history for details I know
UPDATE: See the bottom of this question for what I did to solve the
See update at the end. I am using Ubuntu Linux 11.10, Python 3. I
Update: False alarm! The source of the error was elsewhere. (See at the end
I see that EF can update a model based on an existing database schema.
Update: OK I see it's a bubble sort, but is it less efficient because

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.