title: How to reference more than one controller in one view (CakePHP)
body: <p>I am building an application in CakePHP (I have been using this for a couple of months in a new job, and took over this project from the previous employee, so my understanding is limited).</p>
  
  <p>This application has several database tables, the ones involved in this problem are Centres, Softwares and Categories.</p>
  
  <p>To give you a brief, hat I need, is when a user visits the 'Centres' view, to be able to have a list of all of the software below, and tick which the centres have access to.</p>
  
  <p>To view a list of software, my SoftwaresController uses the function:</p>
  
  <pre><code>public function view() {
  
  $categories = $this-&gt;Software-&gt;Category-&gt;find ('list');
  array_unshift ($categories, array('any' =&gt; 'Any'));
  $this-&gt;set ('categories', $categories);
  $this-&gt;Software-&gt;hasMany['Version']['limit'] = 1;
  $this-&gt;Software-&gt;hasMany['Version']['fields'] = array('Version.id', 'Version.version_number', 'Version.created');
  if ($this-&gt;request-&gt;is ('post') &amp;&amp; $this-&gt;request-&gt;data) {
    $conditions = array();
    $filters = $this-&gt;request-&gt;data['Software'];
    if (!empty($filters['name'])) {
      $conditions['Software.name'] = $filters['name'];
    }
    if ($filters['category'] &gt; 0) {
      $conditions['Category.id'] = $filters['category'];
    }
    $this-&gt;paginate = array(
        'conditions' =&gt; $conditions,
        'order' =&gt; array(
            'Software.latest_released' =&gt; 'desc',
            'Software.name' =&gt; 'asc'
        )
    );
    $this-&gt;set ('softwares', $this-&gt;paginate ());
    $this-&gt;set ('paging', false);
  } else {
    $this-&gt;paginate = array(
        'order' =&gt; array(
            'Software.latest_released' =&gt; 'desc',
            'Software.name' =&gt; 'asc'
        )
    );
    $this-&gt;set ('paging', true);
    $this-&gt;set ('softwares', $this-&gt;paginate ());
  }
  // This allows the user software page to show.
  }
  </code></pre>
  
  <p>In the CentresController function, in which I want to be able to also view the data (as extracted above), looks like this:</p>
  
  <pre><code>public function admin_view($id = null)
  {
  
      /* Centres */
      $this-&gt;Centre-&gt;recursive = 0;
      $this-&gt;Centre-&gt;id = $id;
      if (!$this-&gt;Centre-&gt;exists()) {
          throw new NotFoundException(__('This centre ID does not exist.'));
      }
      $centre = $this-&gt;Centre-&gt;read(null, $id);
      $this-&gt;request-&gt;data = $centre;
      $this-&gt;set('centre', $centre);
  }
  </code></pre>
  
  <p>I have tried to combine the above two functions by adding the inside of view() into admin_view(). The view for admin_view() looks like this:</p>
  
  <p>
                            Assign Software Access</p>
  
  <pre><code>                      &lt;div class="row-fluid"&gt;
                          &lt;div class="span12"&gt;
                            &lt;div class="table-responsive"&gt;
                              &lt;table class="table table-striped table-bordered table-hover"&gt;
                                &lt;thead&gt;
                                &lt;tr&gt;
                                  &lt;th&gt;Version Number&lt;/th&gt;
                                  &lt;th&gt;Created&lt;/th&gt;
                                  &lt;th&gt;Modified&lt;/th&gt;
                                  &lt;th&gt;Released&lt;/th&gt;
                                  &lt;th&gt;Grant Permission&lt;/th&gt;
                                &lt;/tr&gt;
                                &lt;/thead&gt;
                                &lt;tbody&gt;
                                &lt;?php
                                $i = 0;
                                foreach ($software['Version'] as $version):
                                  $class = null;
                                  if ($i++ % 2 == 0) {
                                    $class = ' class="even"';
                                  } else {
                                    $class = ' class="odd"';
                                  }
                                  ?&gt;
                                  &lt;tr&lt;?php echo $class;?&gt;&gt;
                                    &lt;td&gt;&lt;?php echo $version['version_number']; ?&gt;&amp;nbsp;&lt;/td&gt;
                                    &lt;td&gt;
                                      &lt;?php
                                      echo $this-&gt;Time-&gt;format (Configure::read ('Format.time'), $version['created']);
                                      ?&gt;&amp;nbsp;
                                    &lt;/td&gt;
                                    &lt;td&gt;
                                      &lt;?php
                                      echo $this-&gt;Time-&gt;format (Configure::read ('Format.time'), $version['modified']);
                                      ?&gt;&amp;nbsp;
                                    &lt;/td&gt;
                                    &lt;td&gt;
                                      &lt;?php
                                      echo $this-&gt;Time-&gt;format (Configure::read ('Format.time'), $version['released']);
                                      ?&gt;&amp;nbsp;
                                    &lt;/td&gt;
                                    &lt;td class="actions" style="text-align: center;"&gt;
                                      &lt;?php
                                      echo $this-&gt;Html-&gt;link (
                                          '&lt;i class="fa fa-cloud-download"&gt;&lt;/i&gt;&amp;nbsp;Download',
                                          array(
                                              'controller' =&gt; 'versions',
                                              'action' =&gt; 'view',
                                              $version['id']
                                          ),
                                          array('escape' =&gt; false)
                                      );
                                      ?&gt;&amp;nbsp;
  
                                      &lt;/a&gt;
                                    &lt;/td&gt;
                                  &lt;/tr&gt;
                                &lt;?php endforeach; ?&gt;
                                &lt;/tbody&gt;
                              &lt;/table&gt;
                            &lt;/div&gt;
                            &lt;!-- /.table-responsive --&gt;
  
  
  
  
  
  
  
                      &lt;/div&gt;
                  &lt;/fieldset&gt;
                  &lt;div class="col-sm-12 col-md-5 col-lg-4 padding-right-0"&gt;
                      &lt;div class="panel panel-default"&gt;
                          &lt;div class="panel-heading"&gt;&lt;span class="fa fa-cog"&gt;&lt;/span&gt;&amp;nbsp;Actions&lt;/div&gt;
                          &lt;div class="panel-body"&gt;
                              &lt;div class="row"&gt;
                                  &lt;div class="col-sm-4 padding-bottom-10"&gt;
                                      &lt;?php
                                      echo $this-&gt;Form-&gt;button(
                                          '&lt;i class="fa fa-pencil"&gt;&lt;/i&gt;&amp;nbsp;Update',
                                          array(
                                              'type' =&gt; 'submit',
                                              'class' =&gt; 'btn btn-success btn-sm btn-block',
                                              'escape' =&gt; false
                                          )
                                      );
                                      echo $this-&gt;Form-&gt;end();
                                      ?&gt;
                                  &lt;/div&gt;
                                  &lt;!-- /.col-sm-4 padding-bottom-10 --&gt;
                                  &lt;div class="col-sm-4 padding-bottom-10"&gt;
                                      &lt;a class="btn btn-danger btn-sm btn-block" href="#modal-dialog"
                                         data-toggle="modal"
                                         data-target="#modal-dialog"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;&amp;nbsp;Delete&lt;/a&gt;
                                  &lt;/div&gt;
                                  &lt;!-- /.col-sm-4 padding-bottom-10 --&gt;
                                  &lt;div class="col-sm-4 padding-bottom-10"&gt;
                                      &lt;?php
                                      echo $this-&gt;Html-&gt;link(
                                          "&lt;span class='fa fa-times'&gt;&lt;/span&gt;&amp;nbsp;Cancel",
                                          array(
                                              'action' =&gt; 'index'
                                          ),
                                          array(
                                              'escape' =&gt; false,
                                              'class' =&gt; 'btn btn-default btn-sm btn-block'
                                          )
                                      );
                                      ?&gt;
                                  &lt;/div&gt;
                                  &lt;!-- /.col-sm-4 padding-bottom-10 --&gt;
                              &lt;/div&gt;
                              &lt;!-- /.row --&gt;
                          &lt;/div&gt;
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <blockquote>
    <p>Error: Call to a member function find() on null
    File: /Applications/XAMPP/xamppfiles/htdocs/licensemanagementsite/app/Controller/CentresController.php
    Line: 87</p>
  </blockquote>
  
  <p>I have also included at the top of the CentresController and the Centres model:
      App::uses('AppController', 'Controller', 'SoftwaresController');</p>
  
  <p>Any assistance you can give me would be really appreciated. No one in my office knows anything about CakePHP (including me, I guess!).</p>
  
  <p>Thanks!</p>