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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:41:22+00:00 2026-06-03T07:41:22+00:00

My zend layout and scripts are detecting fine. but when in init function of

  • 0

My zend layout and scripts are detecting fine. but when in init function of my IndexController I write $this->view->render(“header.phtml”) It does not show anything one the screen, whereas when I write echo ($this->view->render(“header.phtml”); it displays my header.phtml file. Here is my IndexController

class IndexController extends Zend_Controller_Action
{

public function init()
{
    $layout = $this->_helper->layout();
    //$this->view = $this->getResource('View');
    echo ($this->view->render("header.phtml"));
        //echo"<pre>";
        //var_dump($this->view);
        //var_dump(APPICATION_PATH);
}

public function indexAction()
{
    // action body
    echo "In default index con";
}

}

Also when Igive my url to/mypath/index It does not display the simple line “I’m in index controller” which I’m just echoing. In my bootstrap here is my Zend_Layout settings.

        Zend_Loader::loadClass('Zend_View');
$this->view = new Zend_View();
$this->view->setEncoding('UTF-8');
$this->view->setScriptPath($this->root .'/application/default/views/scripts');
    $viewRenderer=new Zend_Controller_Action_Helper_ViewRenderer();
     // Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     // $view->setScriptPath($this->root.'/'.$theme.'/views/scripts/');
     //$view->setScriptPath($this->root.'/application/default/views/scripts/');
     $this->view->addScriptPath($this->root.'/application/admin/views/scripts');
     $this->view->addScriptPath($this->root.'/application/business/views/scripts');
    // $this->view->setHelperPath($this->root .'/application/default/views/helpers');
     $this->layout = Zend_Layout::startMvc(
        array(
                'layoutPath' => $this->root . '/application/default/views/'.$crt_theme.'/layouts',
                'layout' => 'layout'
                )
                );
        $this->registry->set("theme", $crt_theme);

variable $crt_theme is set to ‘default’.

  • 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-03T07:41:23+00:00Added an answer on June 3, 2026 at 7:41 am

    render() is working as intended; it returns a string that you should then echo.

    It is very unusual to be rendering directly in a controller however. At a minimum, you should be rendering your header and footer from views/scripts/index/index.phtml, though using Zend_Layout would be even better. If you are using Zend_Application, then you can start using Zend_Layout simply by adding:

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

    to your application/config/application.ini file. You then need to create a application/layouts/scripts/layout.phtml file which could look something like this:

    <?php
    $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
    $this->headTitle()->setSeparator(' - ');
    $this->headTitle('My website');
    ?>
    <!DOCTYPE html>
    <html> 
    <head>
        <?php echo $this->headMeta(); ?> 
        <?php echo $this->headTitle(); ?>
        <!-- Other <head> elements and view helpers here -->
    </head>
    <body>
    <div id="content">
        <?php echo $this->layout()->content; ?>
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ahh forgive my Zend newbness, I'm trying to access this form, stored in: layouts/scripts/layout.phtml
the directory structure I'm trying to achieve would be this: application/default/views/layouts/layout.phtml application/default/views/scripts/index/index.phtml application/admin/views/layouts/layout.phtml application/admin/views/scripts/index/index.phtml
In my Zend Framework app, I have following code: index.php $app_started_time = time(); layout.phtml
I set a view variable in someAction function like this: $this->view->type = some type;
when using render or layout()->content, in case the .phtml file is saved as UTF-8,
I'm reading the manual here: http://zendframework.com/manual/en/zend.view.helpers.html but I'm still confused. I have a script
Basically, I want to render a view and layout from a model. Don't ask
I am using Zend Framework, I have a layout.phtml which renders navigation.phtml. How can
I want to generate a dynamic site using Zend_Layout. My layout (/application/layouts/scripts/layout.phtml) contains the
I have a zend framework layout like this: ... <div id=div1></div> <?php echo $this->layout()->content;

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.