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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:52:29+00:00 2026-06-01T14:52:29+00:00

Before I converted my Zend Framework application to a module based structure, it had

  • 0

Before I converted my Zend Framework application to a module based structure, it had a single layout and I could pass variables to it from my controller like so:

// Controller action
$this->view->foo = 'Something';

// Layout
<?= $this->foo ?>

However, since moving everything into a default module and creating a separate “admin” module, I can no longer get this to work, most likely due to me moving my “View Settings” out of my bootstrap file and into the controller plugin where I am switching the layout based on the module. My plugin looks like this:

class KW_Controller_Plugin_LayoutSelector extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $layout = Zend_Layout::getMvcInstance();
        $layout->setLayout($request->getModuleName());

        $view = $layout->getView();
        $view->doctype('HTML5');
        $view->setEncoding('UTF-8');
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8');
        $view->headScript()->appendFile('/js/jquery-1.7.1.min.js');

        switch ($request->getModuleName()) {
            case 'admin':
                $view->headTitle('Admin Area')->setSeparator(' - ');
                $view->headLink()->appendStylesheet('/css/admin/global.css');
                $view->headScript()->appendFile('/js/admin/common.js');
                break;
            default:
                $view->headTitle('Main Site')->setSeparator(' - ');
                $view->headLink()->appendStylesheet('/css/global.css');
                $view->headScript()->appendFile('/js/common.js');
                break;
        }
    }
}

If I move all of those method calls to the view back into my bootstrap, I can pass variables to the layout again; so I’m guessing that something is happening in the wrong order, maybe my layout is being switched after I have passed the variables to the view from my controller and they’re not making it into my layout? (I’ve tried changing the point at which the above runs by putting the code in both preDispatch() and postDispatch(), etc.)

It’s worth noting, that I can access these variables in my individual view scripts, just not the layout that they’re contained within.

Any pointers would be greatly appreciated.

  • 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-06-01T14:52:30+00:00Added an answer on June 1, 2026 at 2:52 pm

    I’m doing something similar in a current project and it’s largely working fine.

    One difference I note is that I am bootstrapping both Layout and View at the app-level using the standard application resources.

    Then in my plugin, I access the view using:

    $front = Zend_Controller_Front::getInstance();
    $view = $front->getParam('bootstrap')->getResource('view');
    

    This seems to guarantee I am accessing the same view instance at bootstrap, in plugins, and in controllers.

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

Sidebar

Related Questions

I recently converted a subversion repo, which had been converted from cvs before that
I have a application built using Zend Framework. I have decided to go with
I've just converted MYISAM into InnoDB. Before doing that, I've saved the table (see
I have converted my old VS2008 Website to Web Application, now everything was working
I upgraded from Struts 2.0.6 to 2.1.6 and converted all my Ajax themes to
I just converted a WPF project from .NET 3.5 to .NET 4.0. I'm now
I have converted a Depth Of Field shader from XNA 3.1 to 4.0. The
Does C++ code gets converted to C before compilation ?
I have an application that I have converted to Delphi 2009 I have String
I upgrade a wpf desktop application from .net 3.5 to .net 4.0.(Changed the target

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.