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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:06:29+00:00 2026-06-16T21:06:29+00:00

I have Zend Framework MVC application with module structure like that above: /application /layouts

  • 0

I have Zend Framework MVC application with module structure like that above:

/application
  /layouts
    /sripts
      /layout.phtml
  /modules
    /default
      /controllers
        /IndexController.php
        /OtherController.php
      /views
        /scripts
          /index
            /index.phtml
            /second.phtml
            /third.phtml
            /fourth.phtml
          /other
            /index.phtml
            /second.phtml
            /third.phtml
            /fourth.phtml

In my layout.phtml i have a line

<div id="main">
    <?= $this->layout()->content ?>
</div>

I want to wrap rendered action views in every action of IndexController and OtherController, except fourth, with some code, like <div id='top'></div> at the beggining, and <div id='bottom'></div> at the end of rendered action view.
I don’t want to do it manually in every action view *.phtml file. There are too many in real application, besides code looks messy with that solution.

How to do it?

  • 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-16T21:06:30+00:00Added an answer on June 16, 2026 at 9:06 pm

    In a layout file, you can echo a layout variable. This is usually where we put the html rendered by an action. You can append the rendering from several actions into a single layout variable, and they will be displayed in LIFO order. Here is how that variable is inserted into the layout file:

    <?php echo $this->layout()->myLayoutVariable; ?>
    

    You can also set up a placeholder variable inside your layout file:

    <?php echo $this->placeholder('myPlaceholderVariable'); ?>
    

    In one of your view files, you can then provide the html content for this placeholder variable:

    <?php
        $this->placeholder('myPlaceholderVariable')->append('<p>HTML GOES HERE</p>');
    ?>
    

    If you don’t set any value for the placeholder variable, nothing will be rendered in the layout file. But if you do set a value for that placeholder variable, it will be inserted into the html.

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

Sidebar

Related Questions

I have a default module in Zend Framework 2: namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController; use
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
All, I have a PHP Web application built using Zend Framework and MVC with
In my Zend Framework app, I have following code: index.php $app_started_time = time(); layout.phtml
All, I have a PHP5 application written with Zend Framework and MVC style. My
I have a zend framework layout like this: ... <div id=div1></div> <?php echo $this->layout()->content;
I am developing a Zend Framework MVC application with some modules, in example, the
I have experienced Zend Framework 1 and I've build some apps with that framework.
I have an application developed in Zend Framework 1.11. I use Zend_OpenId to create
I am creating an MVC application framework, using only libararies and components that I

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.