Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It sounds like you need to look into elements, or else you may be able to embed this into the layout - but its neater to use an element if you ask me, keep the things separate.</p> <p><a href="http://book.cakephp.org/2.0/en/views.html#elements" rel="nofollow noreferrer">http://book.cakephp.org/2.0/en/views.html#elements</a></p> <p>These allow you to have create small views that you are able to embed into other views.</p> <p>You may also need to put some logic into the AppController (remember all other controllers extend the app controller) to load the data required for these views. The beforeRender function should be useful for this - its one of the hook functions cakephp provides, so if you define it on a controller, its always called after the action is finished before the view is rendered.</p> <p>Something like this in your AppController should help:</p> <pre><code>function beforeRender() { $this-&gt;dostuff(); } function doStuff() { // do what you need to do here - eg: load some data. $shortfacts = $this-&gt;ShortFact-&gt;findAll(); $news = $this-&gt;NewsPost-&gt;findAll(); // news and shortfacts will be available within the $shortfacts and $news variables in the view. $this-&gt;set('shortfacts', $shortfacts); $this-&gt;set('news', $news); } </code></pre> <p>If there are models you need in the app controller for use within this doStuff method, then you need to define them within uses at the top of the AppController</p> <pre><code>class AppController { var $uses = array('NewsPost', 'ShortFact'); } </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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