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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:50:55+00:00 2026-06-17T13:50:55+00:00

I am building a Zend Framework MVC application and am having difficultly configuring my

  • 0

I am building a Zend Framework MVC application and am having difficultly configuring my Zend_Layout.

Firstly, my application resources are all in resource plugins which are loaded in bootstrap with the following code:

protected function _initResourcePlugins() {

    $this->registerPluginResource('Log');        
    $this->registerPluginResource('Router'); 
    $this->registerPluginResource('Db');        
    $this->registerPluginResource('View');
}

I have not created a resource plugin for my Layout because I am handling login/logout in a front controller plugin and my layout configuration depends on whether the user is logged in or not (and other context-related information). I am kicking the layout in to life with the following lines in my application.ini:

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/professional"
resources.layout.layout = "ver1"

Then I use a front controller plugin to configure it. Here’s the plugin:

public function postDispatch(\Zend_Controller_Request_Abstract $request) {

    $layout = Zend_Layout::getMvcInstance();        
    $path   = $layout->getLayoutPath();

    // include static content
    $layout->header = include($path . '/includes/header.phtml');
    $layout->footer = include($path . '/includes/footer.phtml');

    if(APPLICATION_ENV == 'development') {
        $layout->dev    = include($path . '/includes/dev.phtml');                    
    }

    if(RW_Helper::isLoggedIn()) {
        $layout->sidebar = include($path . '/includes/sbar_secure.phtml');                    
    } else {
        $layout->sidebar = include($path . '/includes/sbar_public_login.phtml');            
    }
}

(I know its not particularly pretty but I’ll deal with that later).

Now, the problem is that the only event I can run this on is the postDispatch event. If I try to run it on, say, dispatchLoopStartup, I get an error such as “Warning: UiWidgetElement decorator cannot render without a registered view object in …“

I’m not sure which view object it is looking for. (Are there separate ones for the Layout and the Application view?) And I’m not sure where/how I should be injecting it or providing it. If it’s chasing the view that I set up as a resource, I would have thought it could find it easily enough by consulting the bootstrap…

I don’t really want to leave the Layout attached to the postDispatch event because a) it doesn’t feel semantically correct, and b) I risk executing it more than once (if I execute multiple actions in a request).

What am I missing?

Thanks!

  • 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-17T13:50:56+00:00Added an answer on June 17, 2026 at 1:50 pm

    From the look of the code it’s trying to access to the view object from the view renderer. This gets initialised automatically postDispatch, so that’s why your code only works as a postDispatch hook.

    I think part of the pain you are experiencing is because you are trying mix application and presentation logic by trying to render templates during the dispatch process. You said in your question that your plugin code wasn’t particularly pretty but you can easily simplify this and solve your issue at the same time.

    I’d suggest removing this plugin completely, and then rendering these templates from within the layout itself, e.g.:

    <?=$this->render('includes/header.phtml')?>
    

    The login check you could either to in the layout in the same way or move this to a view helper. Since the view object will have already been setup, this should fix your problem.

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

Sidebar

Related Questions

Im currently building a controller from my Zend MVC application which would only be
I am building a Zend Framework application that performs jobs submitted by the user.
I'm building a Zend Framework 1.11.11 application and would like to make the routes
I'm building a web application using PHP5.3 and Zend Framework 1.9.4. i have an
I am building an application based on the Zend Framework, and my issue is
Long story short: I'm building a skeleton application for Zend Framework and I got
I'm building a web application with the Zend Framework. I have wanted to include
I'm building a multi-site Zend Framework application using modules, sort of in the following
I'm building a Q&A site like StackOverflow with Zend Framework. It's all set except
I'm building an application on Zend Framework and now there is requirement to manipulate

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.