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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:56:53+00:00 2026-05-19T23:56:53+00:00

I have this layout file called menuAdmin. I wish to, each time a given

  • 0

I have this layout file called menuAdmin.
I wish to, each time a given controller and a given action is active, to show the “li” element with a specific class.

So, I have the following on my menuAdmin.php :

<li <?php echo ($this->controller == "d" && $this->action == "a") ? "class='selectedMenuItem'" : ''; ?>><a href="<?php echo $this->url(array("controller"=>"d","action"=>"a.d"))?>">Aaaa Dddd</a></li>

I get nothing with this, and if I dump:
var_dump($this->controller); and var_dump($this->action); I get NULL NULL

  • So I believe Zend don’t trigger those at that point.

Question:
How can I accomplish such a task? Should I follow this path? If so, how will my menuAdmin layout know about what controller and action is in place?

Update:
menuAdmin.php is a layout file, inside Layouts folder on Zend structure.
This is a large application and the structure in place is already like this – using layout files as menus where this is just one of them.

So $this->controller and $this->action only work inside the controller, OR if I explicitly pass it to the view. On this case, however, I would like to call it on the layout. Why there? Because by doing so, I can make one change and allow that change to be replicated all over the views that use this layout.

Regarding the above clarifications, could your answers change ?

Update 2:
I don’t know if this is relevant or not but, all this menuadmin layout is called from a main layout file “layouts/main.php” and there we have: <?php echo $this->render("menuadmin.php"); ?>

Thanks again

  • 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-19T23:56:54+00:00Added an answer on May 19, 2026 at 11:56 pm

    Depending on what menuAdmin.php is you can get the controller and action in a variety of ways.

    If your file is a controller you can do one of the following, they all do the same thing

     $controller = $this->getRequest()->controller;
     $controller = $this->getRequest()->getParam("controller");
     $controller = $this->getRequest()->getControllerName();
    

    Ideally you should use Zend_Navigation to do this though.

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

Sidebar

Related Questions

I have this big data-entry sort of page, a table kind of layout using
This is different than the simple 2 column layout. I need to have this
I have a layout similar to this: <div id=...><img src=...></div> and would like to
Has anyone run into this problem... In my layout.phtml I have: <head> <?= $this->headTitle('Control
I have an excel file which I've been supplied a layout for with the
I have this code in jQuery, that I want to reimplement with the prototype
I have this idea for a free backup application. The largest problem I need
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM
I have this line in a javascript block in a page: res = foo('<%=
I have this setup where in my development copy I can commit changes on

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.