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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:54:49+00:00 2026-06-07T08:54:49+00:00

I am new to zendframework . I am trying to implement two step view

  • 0

I am new to zendframework . I am trying to implement two step view lay out:

Bootstrap.php(view/Bootstrap.php)

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

     public function _initRoutes()
    {
        $options = array(
    'layout'     => 'layout',
    'layoutPath' => '/layout/layout.phtml',);
$layout = Zend_Layout::startMvc($options);
    }
}?>

layout.phtml(application/view/scripts/layout/layout.phtml)

<?php
        include "header.php";

?>
// view contents goes here.
<?php

       $this->layout()->content;

?>
// footer goes here.
<?php
        include "footer.phtml";
?>

i am a absolute beginner step by step explanation is more appreciated .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-07T08:54:50+00:00Added an answer on June 7, 2026 at 8:54 am

    The easiest way to enable layouts is to run the Zend_Tool command from the command line zf enable layout, this will add the line
    resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
    to your application.ini and build the directory for the layout and the default file layout.phtml.

    Alternatively you can specify your layout path and default layout name with 2 lines in your application.ini file:

    resources.layout.layoutPath = APPLICATION_PATH "/layouts" //path to layout
    resources.layout.layout = master //name of layout without extension
    

    other layout/view options may be set in your application.ini to be callled in your view:

    ;View Settings
    ;*************
    resources.view[]=
    resources.view.charset = "UTF-8"
    resources.view.encoding = "UTF-8"
    resources.view.doctype = "HTML5"
    resources.view.language = "en"
    resources.view.contentType = "text/html; charset=UTF-8"
    

    then in your bootstrap.php you can call on these resources to initialize your view:

     /**
         * initialize the registry and asign application.ini to config namespace
         */
        protected function _initRegistry() {
    
            //make application.ini configuration available in registry
            $config = new Zend_Config($this->getOptions());
            Zend_Registry::set('config', $config);
        }
    
        /**
         * initialize the view and return it
         * @return \Zend_View
         */
    protected function _initView() {
            //Initialize view
            $view = new Zend_View();
            //add custom view helper path
            $view->addHelperPath('/../library/Application/View/Helper');
            //set doctype for default layout
            $view->doctype(Zend_Registry::get('config')->resources->view->doctype);
            //set default title
            $view->headTitle('Our Home');
            //set head meta data
            $view->headMeta()->appendHttpEquiv('Content-Type', Zend_Registry::get(
                            'config')->resources->view->contentType);
            //set css includes
            $view->headLink()->setStylesheet('/css/normalize.css');
            $view->headLink()->appendStylesheet('/css/blueprint/src/liquid.css');
            $view->headLink()->appendStylesheet('/css/blueprint/src/typography.css');
            $view->headLink()->appendStylesheet(
                    '/javascript/mediaelement/build/mediaelementplayer.css');
            $view->headLink()->appendStylesheet('/css/main.css');
            $view->headLink()->appendStylesheet('/css/nav.css');
            $view->headLink()->appendStylesheet('/css/table.css');
            //add javascript files
            $view->headScript()->setFile('/javascript/mediaelement/build/jquery.js');
    
            //add it to the view renderer
            $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
                            'ViewRenderer');
            $viewRenderer->setView($view);
            //Return it, so that it can be stored by the bootstrap
            return $view;
        }
    

    I also included a convenience method _initRegistry() to make config options available everywhere with minimal code.

    The layout in ZF is a simple html page with placeholder added for dynamic or configured options:

    <?php
    echo $this->doctype() . "\n"; //placeholder assigned in bootstrap $view->doctype
    ?>
    <html>
        <head>
            <title></title>
            <?php echo $this->headMeta() . "\n" //placeholder assigned in bootstrap ?>
            <?php echo $this->headLink() . "\n" //placeholder assigned in bootstrap ?>
            <?php echo $this->headscript(). "\n" //placeholder assigned in bootstrap?>
        </head>
        <body>
            <section class="container">
                <header class="block">
                    <hgroup id="header" class ="column span-24">
                        <h1>Our Page</h1>
                    </hgroup>
                    <nav>
                        <div id="nav" class="column span-24">
                            <?php echo $this->layout()->nav //custom placeholder ?>
                        </div>
                    </nav>
                </header>
                <section class="block">
                    <div id="main" class="column span-18 border">
                        <div id="flash">
                            <?php
                            //flash messenger display location
                            if (count($this->messages) > 0) {
                                printf("<h3 id='flash'>%s</h3>", $this->messages[0]);
                            }
                            ?>
                        </div>
                        <?php echo $this->layout()->content; //placeholder for redering views ?>
                    </div>
                    <aside id="sidebar" class="column span-4 last">
                        <?php echo $this->layout()->search //custom placeholder ?>
                        <div id="subNav">
                            <?php echo $this->layout()->subNav //custom placeholder ?>
                        </div>
                        <div id="adminMenu">
                            <?php echo $this->layout()->adminMenu //custom placeholder ?>
                        </div>
                    </aside>
                </section>
                <footer class="block">
                    <div id="footer" class="column span-24">
                        <p>Created by <em>Your Name</em> with <a href="http://framework.zend.com/">Zend Framework. &COPY; </a></p>
                    </div>
                </footer>
            </section>
        </body>
    </html>
    <?php echo $this->inlineScript() ?> //javascript includes at bottom of page
    

    Hope this helps.

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

Sidebar

Related Questions

I am rather new to ZendFramework and am trying to figure this out. In
I am just trying to test out the new Zend Studio 7.2, and in
I'm new to the Zend Framework and trying to figure some stuff out. I
I'm just new to Zend Framework. Currently what I'm trying to do is when
I am trying to use the new Eventmanager of the Zend Framework 2. I
I'm new to Zend Framework. I would like to know how to implement zend
im new in PHP and I want to know about PHP Zend Framework. What
I'm new to php and zend framework and fill very uncertain about following: For
New to PHP and MySQL, have heard amazing things about this website from Leo
I'm trying to implement this basic example found here : under the section titled

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.