title: cakephp 3 display html according to users role
body: <p>I am making a app with cakephp 3. My users have 2 roles, admin and students. The admin can see everything and the student can see and edit only his profile. the roles are a field in the users table in the database.</p>
  
  <p>the ctp files of the admin have many links to do differents actions, like add a new product o delete an user, what i want to do is display this links just to the admin role, but use the same ctp file for students and admins. I have no idea how to do this, if someone can give me an example please.</p>
  
  <p>for example this is the add.ctp file for users:</p>
  
  <pre><code>&lt;div class="actions columns large-2 medium-3"&gt;
  &lt;h3&gt;&lt;?= __('Actions') ?&gt;&lt;/h3&gt;
  THIS ARE THE LINKS
  &lt;ul class="side-nav"&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Users'), ['action' =&gt; 'index']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Clase'), ['controller' =&gt; 'Clases', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Convenios Usuarios'), ['controller' =&gt; 'ConveniosUsuarios', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Convenios Usuario'), ['controller' =&gt; 'ConveniosUsuarios', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Desvinculaciones'), ['controller' =&gt; 'Desvinculaciones', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Desvinculacione'), ['controller' =&gt; 'Desvinculaciones', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Historial Alumnos'), ['controller' =&gt; 'HistorialAlumnos', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Historial Alumno'), ['controller' =&gt; 'HistorialAlumnos', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Pagos'), ['controller' =&gt; 'Pagos', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Pago'), ['controller' =&gt; 'Pagos', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('List Pedidos'), ['controller' =&gt; 'Pedidos', 'action' =&gt; 'index']) ?&gt;&lt;/li&gt;
      &lt;li&gt;&lt;?= $this-&gt;Html-&gt;link(__('New Pedido'), ['controller' =&gt; 'Pedidos', 'action' =&gt; 'add']) ?&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;div class="users form large-10 medium-9 columns"&gt;
  &lt;?= $this-&gt;Form-&gt;create($user) ?&gt;
  &lt;fieldset&gt;
      &lt;legend&gt;&lt;?= __('Agrega Nuevo Usuario') ?&gt;&lt;/legend&gt;
      &lt;?php
          echo $this-&gt;Form-&gt;input('nombre', ['label'=&gt;'Nombre Completo']);
          echo $this-&gt;Form-&gt;input('fecha_nac',['label'=&gt;'Fecha de Nacimiento']);
          echo $this-&gt;Form-&gt;input('username',['label'=&gt;'Nombre de Usuario']);
          echo $this-&gt;Form-&gt;input('email');
          echo $this-&gt;Form-&gt;input('password', ['label'=&gt;'Contraseña']);
          echo $this-&gt;Form-&gt;input('telefono');
          echo $this-&gt;Form-&gt;input('rol', ['options' =&gt;['Alumno'=&gt;'Alumno', 'Monitor'=&gt;'Monitor','Instructor'=&gt;'Instructor']]);
          echo $this-&gt;Form-&gt;input('fecha_ing',['label'=&gt;'Fecha de Ingreso']);
          echo $this-&gt;Form-&gt;input('profesion');
          echo $this-&gt;Form-&gt;input('grado_id', ['options' =&gt; $grados]);
          echo $this-&gt;Form-&gt;input('referencia');
          echo $this-&gt;Form-&gt;input('estado', ['options' =&gt;['Activo','Inactivo']]);
          echo $this-&gt;Form-&gt;input('fecha_ult_acenso', ['label'=&gt;'Fecha último ascenso','empty' =&gt; true, 'default' =&gt; '']);
          echo $this-&gt;Form-&gt;input('nombre_apoderado', ['empty' =&gt; true, 'default' =&gt; 'No tiene Apoderado']);
          echo $this-&gt;Form-&gt;input('telefono_apoderado',  ['empty' =&gt; true, 'default' =&gt; '']);
          echo $this-&gt;Form-&gt;input('nota_salud',['label'=&gt;'Información de Salud', 'empty' =&gt; true, 'default' =&gt; 'No presenta Complicaciones']);
          echo $this-&gt;Form-&gt;input('llevar_a', ['label'=&gt;'En caso de Emergencia', 'empty' =&gt; true, 'default' =&gt; '']);
          echo $this-&gt;Form-&gt;input('monto_paga',['label'=&gt;'Mensualidad']);
          echo $this-&gt;Form-&gt;input('id_user_referencia', ['label'=&gt;'Quien Paga']);
          echo $this-&gt;Form-&gt;input('observaciones', ['empty' =&gt; true, 'default' =&gt; 'No tiene observaciones']);
          echo $this-&gt;Form-&gt;input('fecha_cambio_password', ['empty' =&gt; true, 'default' =&gt; '']);
          echo $this-&gt;Form-&gt;file('foto');
      ?&gt;
  &lt;/fieldset&gt;
  &lt;?= $this-&gt;Form-&gt;button(__('Agregar')) ?&gt;
  &lt;?= $this-&gt;Form-&gt;end() ?&gt;
  </code></pre>
  
  <p></p>
  
  <p>My first idea is to use and if in the ctp file and have two list of links and display one or other according to the user's role, but i dont know if there is a better form to do that, using the tools of cakephp.</p>