Note that there are some explanatory texts on larger screens.

plurals
  1. POZend organization question
    primarykey
    data
    text
    <p>So I had a question on general organization of code for the Zend framework with regard to the layout.</p> <p>My layout is basically this:</p> <pre><code>(LAYOUT.PHTML) &lt;div id='header'&gt; &lt;?= $this-&gt;Layout()-&gt;header ?&gt; &lt;/div&gt; &lt;div id='main'&gt; &lt;?= $this-&gt;Layout()-&gt;main ?&gt; &lt;/div&gt; &lt;div id='footer'&gt; &lt;?= $this-&gt;Layout()-&gt;footer ?&gt; &lt;/div&gt; </code></pre> <p>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:</p> <pre><code>(INDEX.PHTML) $this-&gt;Layout()-&gt;header = file_get_contents('index/header.phtml'); $this-&gt;Layout()-&gt;main = file_get_contents('index/main.phtml'); $this-&gt;Layout()-&gt;footer = file_get_contents('index/footer.phtml'); </code></pre> <p>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?</p> <p>If not is there a way to do it so that I can have:</p> <ol> <li><p>The ability to put code into different sections of my layout, such as Layout()->header, Layout->footer.</p></li> <li><p>Separate these pieces into different files, so that they're easy to find and organize, like my index/footer.phtml, index/main.phtml etc.</p></li> <li><p>Not have to put that code into quotes unnecessarily to turn it into a string to pass it to Layout()->header etc.</p></li> </ol> <p>Thank you guys so much for your help.</p> <p>-Ethan</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload