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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:14:10+00:00 2026-05-22T14:14:10+00:00

PROBLEM: I can’t pass my variables to my custom layout from action helper’s init

  • 0

PROBLEM: I can’t pass my variables to my custom layout from action helper’s init method.

I have this action helper “My_Action_Helper_Initializer”:

class My_Action_Helper_Initializer extends Zend_Controller_Action_Helper_Abstract
{
 public function init()
 {
  $controller=$this->getActionController();
  //variable passed to controller's view
  $controller->view->flop="FLOOP!!";
  //variable passed to controller
  $controller->boom="BOOM!!";
 }
}

In my controller “IndexController”:

class IndexController extends Zend_Controller_Action
{ 
  public function indexAction()
  {
    //print the variable passed from action helper
    echo $this->boom;
  }
}   

then in my “layout.phtml”:

//print variable passed from action helper
echo $this->flop;
  • So the “boom” variable echoed out by controller action is shown correctly.

  • The “flop” variable (passed to my layout) is not shown.

    QUESTION: Why the variable passed to controller action is correctly output while the other one passed to the layout view is not?

Thanks

Luca

  • 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-22T14:14:11+00:00Added an answer on May 22, 2026 at 2:14 pm

    When your helper’s init() called, ViewRenderer’s init() wasn’t yet. This is because of order in helpers stack.

    If you enable strict standards error reporting, you should see something like this in your helper “Creating default object from empty value in …”

    You should consider moving your code to preDispatch() hook as init() method should be used for helper initialization.

    To get view instance for controller:

    function getView()
    {
        $controller = $this->getActionController();
        if($view = $controller->view) {
            return $view;
        }
    
        if($this->getFrontController()->getParam('noViewRenderer') {
            return $controller->initView();//this view instance will not be used in Zend_Layout!
        }
        $vr = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
        return $vr->initView();      
    
    }
    

    if you want to pass parameter to layout, then use

    $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->initView();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem - i can't compile SqlCipher. I'm using this http://groups.google.com/group/sqlcipher/browse_thread/thread/55c6296b56bf4533/c792bbec6df7d4f4?tvc=2#c792bbec6df7d4f4 instructions
From what I've been seeing around the internet, this problem can't really be solved
I think that this problem can be sorted using reflection (a technology which I'm
I have a problem and can't solve it alone. My teacher gives me one
I've got a problem I can't find any solution for. I have a textfile
there's this interesting problem i can not solve myself. I will be very glad,
this must be such a simple problem but can someone tell me why this
This is a strange LINQ-to-SQL problem which can't evaluate as an Enumerable (in SQL)
I've created a custom exception for a very specific problem that can go wrong.
I can't solve this problem can you help me please. <%@ page language=java contentType=text/html;

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.