title: add values to cakephp layout from model app wide
body: <p>thanks for reading, I know the question might sound fairly common, and well I wont deny the fact that maybe I'm just formulating what i want wrongly.</p>
  
  <p>Lets start by shooting it straight, then specifying.</p>
  
  <p>I have a cakephp app with 2 layouts, one layout renders the whole "public" page, and lets call it admin "admin" layout that will render only actions to authenticated users.</p>
  
  <p>in my admin layout, I am printing an element which is the navigation bar.</p>
  
  <p>what I want to do is, without setting on every single controller, the options to set a variable containing the navigation bar values (yes dynamically filled from a specific model)</p>
  
  <p>I want to be able, to set a variable, which will contain a list of values gotten from a model.</p>
  
  <p>The Model is called "Section", which is a table, that contains a list of "sections" of the application.</p>
  
  <p>this navigation bar, needs to print the values of each section, so I need them to be dynamic, hence, I think (again I might be wrong) i need to set that variable somewhere, to make it available to the element, so when the layout "admin" is rendered, the menu bar, is actually filled with the available values of the sections.</p>
  
  <p>I tried doing a Configure::write on AppController, but no dice, it just allowes me to use a variable on controllers, when what I want to do is, loop through the arrah "sections_for_menu" or whatever we call it, and then print the options avaliable on the menu bar.</p>
  
  <p>so you are a bit more comfortable with the idea, the nav bar is a bootstrap based "navbar" with "dropdowns".</p>
  
  <p>i should be able to
  </p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;ul class="mycoolclass"&gt;
  &lt;?php    
  foreach($sections as $section) { 
      echo '&lt;li&gt;&lt;a href="whatever"&gt;" . $section . "&lt;/a&gt;&lt;/li&gt;'; 
  }
  &lt;/ul&gt;
  </code></pre>
  
  <p>and thus, printing each value on a new list with its link, and whatnot.</p>
  
  <p>I have been reading with no luck, and have to admin that I am myself fairly new to cakephp, been using it for no longer than 2 weeks.</p>
  
  <p>Any help reaching a solution to this need, is highly appreciated.</p>
  
  <p>UPDATE:</p>
  
  <p>Hi @nunser, thank you very much for your reply.</p>
  
  <p>indeed I'm using an element
  this is my layout "base"</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;body&gt;
  &lt;?php echo $this-&gt;element('admin_navbar'); ?&gt;
  &lt;!-- container --&gt;
  &lt;div class="container-fluid"&gt;
  &lt;!-- , array('element' =&gt; 'flash') --&gt;
  &lt;?php echo $this-&gt;Session-&gt;flash('flash'); ?&gt;
  &lt;?php /*echo $this-&gt;fetch('content');*/echo $content_for_layout; ?&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I'll try your suggestion and see how it goes</p>
  
  <p>I have a controller "SectionsController" which is in charge of well all Section related actions on the app, what I need is to set in the global variable, a list of sections, so I can print the link inside my navbar!</p>
  
  <p>lets assume the following scenario</p>
  
  <pre class="lang-php prettyprint-override"><code>$this-&gt;set('sections_for_navigation', $this-&gt;Section-&gt;find('list', array('fields' =&gt; array('id', 'name'))));
  </code></pre>
  
  <p>so then i can access the variable $sections_for_navigation from my element, and render the list of sections.</p>
  
  <p>[19-02-2014 - update] tried it.</p>
  
  <p>based on what @nunser suggested, im actually able to, beforeFilter, setting the value, as if i var_dump it, it actually gives me the array as i expected.</p>
  
  <pre class="lang-php prettyprint-override"><code>public function beforeFilter(){
      $this-&gt;loadModel('Section');
      $secciones = $this-&gt;Section-&gt;find(
          'list', array(
              'fields' =&gt; array(
                  'id',
                  'name'
              )
          )
      );
      $this-&gt;set('navigation', $secciones);
  </code></pre>
  
  <p>Then call </p>
  
  <pre class="lang-php prettyprint-override"><code>public function beforeFilter() {
      parent::beforeFilter();
  }
  </code></pre>
  
  <p>from the controllers, did the trick!, now, do i have to add a beforeFilter to every controller to share the navigation through all the app?, is there a way to avoid having to add that method to every single controller? (not that it bothers me, so far it does what i need,which is actually great)</p>