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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 145k
  • Answers 145k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OK, this is what I was looking for: from django.core.files.base… May 12, 2026 at 8:46 am
  • Editorial Team
    Editorial Team added an answer Rather than updating records, just calculate the accrued interest on… May 12, 2026 at 8:46 am
  • Editorial Team
    Editorial Team added an answer It depends entirely on the implementation of the classes in… May 12, 2026 at 8:46 am

Related Questions

My company has recently started using Scrum; we've done 2 sprints. We're still learning,
Ok, I had a simple layout problem a week or two ago. Namely sections
I just caught myself doing something I do a lot, and wanted to generalize
We're looking for someone to help us enhance & maintain our high-quality, php-based prototype

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.