1
resposta

Dúvida ao utilizar as views

Boa noite, queria saber como utilizar a view sem renderiza o layout padrão do sistema por exemplo. se eu uso user/login ele carregar o template do site no default eu queria personalizar a tela de login sem que renderizasse o menu acima.

<?php
/**
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 * @link          https://cakephp.org CakePHP(tm) Project
 * @package       app.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       https://opensource.org/licenses/mit-license.php MIT License
 */
?>
<!DOCTYPE html>
<html>
<head>
    <?php echo $this->Html->charset(); ?>
    <title>Task</title>
    <?php
        echo $this->Html->meta('icon');

        echo $this->Html->script("/js/jquery");
        echo $this->Html->script("/js/bootstrap.min");
        echo $this->Html->css("/css/bootstrap.min");
        echo $this->Html->css("/css/custom");
    ?>
</head>
<body>
    <div id="container">
        <div id="header">
            <nav class="navbar navbar-inverse">
              <div class="container-fluid">
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>                        
                  </button>
                  <a class="navbar-brand" href="/">Logo</a>
                </div>
                <div class="collapse navbar-collapse" id="myNavbar">
                  <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="/category">Categorias</a></li>
                    <li><a href="/project">Projetos</a></li>
                    <li><a href="/task">Tarefas</a></li>
                  </ul>
                  <ul class="nav navbar-nav navbar-right">
                      <?php if ($loggedIn) { ?>
                        <li><a href="/users/logout"><span class="glyphicon glyphicon-log-out"></span> Sair</a></li>
                    <?php }else{} ?>
                  </ul>
                </div>
              </div>
            </nav>
        </div>
        <div id="row content">
            <?php echo $this->Flash->render(); ?>
            <?php echo $this->fetch('content'); ?>
        </div>
        <div id="footer">
            <footer class="container-fluid text-center">
              <p>Desenvolvido por Yuri Neves</p>
            </footer>
        </div>
    </div>
    <?php echo $this->element('sql_dump'); ?>
</body>
</html>

Onde está o content, quero personalizar apenas uma view sem usar o fetch.

1 resposta

Você pode criar um novo arquivo de LAYOUT sem o menu e guarda-lo em src/Template/Layout/ .

E depois indicar no Controller qual layout será utilizado na exibição da view.

 $this->layout = 'admin';

Na documentação do cake tem mais detalhes: https://book.cakephp.org/3.0/pt/views.html