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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:43:01+00:00 2026-05-11T21:43:01+00:00

So I had a question on general organization of code for the Zend framework

  • 0

So I had a question on general organization of code for the Zend framework with regard to the layout.

My layout is basically this:

(LAYOUT.PHTML)

<div id='header'>
<?= $this->Layout()->header ?>
</div>

<div id='main'>
<?= $this->Layout()->main ?>
</div>

<div id='footer'>
<?= $this->Layout()->footer ?>
</div>

and so on and so forth. Now, in order to keep my code in my header separate from the code of my main and the code of my footer, I’ve created a folder for my view that holds header.phtml, main.phtml, footer.phtml. I then use this code to assign the content of header.phtml into $this->layout()->header:

(INDEX.PHTML)

$this->Layout()->header = file_get_contents('index/header.phtml');
$this->Layout()->main = file_get_contents('index/main.phtml');
$this->Layout()->footer = file_get_contents('index/footer.phtml');

That was working great, but I’ve hit a point where I don’t want main to be static HTML anymore. I would like to be able to insert some values with PHP. So in my Controller in indexAction, I want to be able to load from my database and put values into index/main.phtml. Is there a way to do this without restructuring my site?

If not is there a way to do it so that I can have:

  1. The ability to put code into different sections of my layout, such as Layout()->header, Layout->footer.

  2. Separate these pieces into different files, so that they’re easy to find and organize, like my index/footer.phtml, index/main.phtml etc.

  3. Not have to put that code into quotes unnecessarily to turn it into a string to pass it to Layout()->header etc.

Thank you guys so much for your help.

-Ethan

  • 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-11T21:43:02+00:00Added an answer on May 11, 2026 at 9:43 pm

    Here is an idea:

    • Assign layout()->header the filename instead of the contents.
    • Put your code in this file
    • In your layout file, include() or require() the layout->header().

    Since your layout headers/footers are now parsed, you can use them just like a view.

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

Sidebar

Related Questions

I had a general question of what is going on when code like this
I had a general question about extracting code from a visual studio web test.
This is just a general/vague question, If i had a textarea... <textarea class=mybox> myfirststring
This is a question I had about working with the Kohana framework, though I
just had a general question about how to approach a certain problem I'm facing.
I had this question earlier and it was concluded it was a bug in
We've had this question already, but I want to narrow it down to already
This is a very general question but it's based on a specific problem. I've
This started out as a general user question on Android forums. However it's become,
Please note this is a question with regard to Backbone.js. This is not a

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.