Problem to route in cakephp

1

I have a small problem, they are really two but I think I can not ask two questions on this page.

Bno I'm creating a new button, on a page, I literally copy it from another and do not get the changes here I show you the codes:

Button codes on which I'm based ConfigController.php

public function assesor_index($active_pill = null)
    {
        $this->layout = 'assesor';

        $user = $this->Auth->user();

        $doctor = $user['Doctor'];

        $pendings = $this->AppointmentUser->find('all', array(
            'conditions' => array('appointment_state_id' => '1', 'doctor_id' => $user['Doctor']['id']),
            'order' => array('date_created DESC')));
        $appointments = $this->AppointmentUser->find('all', array(
            'conditions' => array('appointment_state_id' => '2', 'doctor_id' => $user['Doctor']['id']),
            'order' => array('date_created DESC')));
        $effectives = $this->AppointmentUser->find('all', array(
            'conditions' => array('appointment_state_id' => '3', 'doctor_id' => $user['Doctor']['id']),
            'order' => array('date_created DESC')));
        $todoctor = $this->AppointmentUser->find('all', array(
            'conditions' => array('appointment_state_id' => '4', 'doctor_id' => $user['Doctor']['id']),
            'order' => array('date_created DESC')));
        $noteffective = $this->AppointmentUser->find('all', array(
            'conditions' => array('appointment_state_id' => '5', 'doctor_id' => $user['Doctor']['id']),
            'order' => array('date_created DESC')));

        $this->set(compact('appointments', 'pendings', 'effectives', 'todoctor', 'doctor', 'noteffective', 'active_pill'));
    }

Here is located the menu which is in elements and is called assesor_menu.ctp, the second li was the one that I believe, and I based on the first one to create it but it does not work

<li>
        <?php
            echo $this->Html->link('<div><i class="fa fa-user-md fa-fw"></i> Consultas </div>', 
                            array('controller' => 'config', 'action' => 'index', 'assesor' => true), 
                            array('escape' => false));
        ?>
        </li>
           <li>
        <?php
            echo $this->Html->link('<div class="clickPoliticasWeb"><i class="fa fa-user-md fa-fw"></i> Politicas del sitio web</div>', 
                            array('controller' => 'config', 'action' => 'index', 'politics' => true), 
                            array('escape' => false));
        ?>
        </li>
        <li>
                <?php
                    echo $this->Html->link('<i class="fa fa-sign-out fa-fw"></i> Salir', 
                            array('controller' => 'users', 'action' => 'logout', 'admin' => true), 
                            array('escape' => false)
                    );
                ?>
                </li>

The weird thing is that in the source code there is another route The route should be the policy / config ps of the button that already existed is assesor / config

Layouts: Assesors.ctp and Politics.ctp for now have the same, but Politics does not charge me as if I did not find it. The only difference is that one of the two I put an input text, and if that input is in politics does not show it, if it is in assesors, ps if it shows it.

<?php



$pageDescription = __d('seadog_base', 'SEADOG Base');
$pageName = __d('seadog_base', 'IQ Administración');
?>

<!DOCTYPE html>
<html lang="es-ES">
<head>
    <?php echo $this->Html->charset(); ?>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>
        <?php echo $pageName.' :'; ?>
        <?php echo $title_for_layout; ?>
    </title>

    <?php 
        echo $this->Html->meta('keywords','SEADOG, dessign, creativity, lab, Endor inc');
        echo $this->Html->meta('description', 'Seadog base template');
        echo $this->Html->meta('language', 'es');

        echo $this->Html->meta('favicon.ico', '/img/favicon.ico', array('type' => 'icon')); 

        /* CSS */
        echo $this->Html->css(array(
            'bootstrap.min',
            'metisMenu.min',
            'admin', 
            'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css',
        ));

        /* JS */
        echo $this->Html->script(array(
            'jquery.min',   
             '../ckeditor/ckeditor', '../ckeditor/config', /* ckeditor */ 
        ));
        //this is loaded at the end of the page.
        echo $this->Html->script(array(
            'metisMenu.min',
            'bootstrap.min',
            'admin', 
            ), array('async' => 'async', 'block' => 'scriptBottom') 
        );

        echo $this->fetch('meta');
        echo $this->fetch('css');
        echo $this->fetch('script');
    ?>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

<div id="wrapper">

    <!-- Navigation -->
    <?php echo  $this->element('assesor_menu'); ?>

    <!--nocache-->  
    <!-- display session messaging -->
    <div id="flassMessage" class="container">
        <?php $flashMessage = $this->Session->flash();
            if($flashMessage){
                echo '<div class="alert alert-warning alert-dismissable">
                                 <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
                echo $flashMessage;
                echo '</div>';  
            }

            $flash_auth = $this->Session->flash('auth'); 
            if($flash_auth){
                echo '<div class="alert alert-warning alert-dismissable">
                                 <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>';
                echo $flash_auth;
                echo '</div>';
            }
        ?>
    </div> <!-- end flash -->
    <!--/nocache-->     

    <!-- display page content -->
    <input type="text" name="vlr">
    <?php echo $this->fetch('content'); ?>

</div> <!-- end wrapper -->

<?php echo $this->fetch('scriptBottom'); //header scripts ?>    
<?php echo $this->element('sql_dump'); ?>
<?php echo $this->Js->writeBuffer(); // Write cached scripts ?>


</body>
</html>

Policy controller

public function politics_index($active_pill = null)
    {
        $this->set(compact());
    }

photo change 1:

It's like when i try to enter:

 <a href="/politics/config"><div><i class="clickPoliticasWeb fa fa-user-md fa-fw"></i> Politicas del sitio web</div></a>        </li>

will not leave me

    
asked by Andrés Vélez 20.04.2018 в 16:51
source

1 answer

0

The reason it does not work is because you have not declared the prefix in core.php .

The HtmlHelper, since it does not have that prefix in the configuration, is taking 'politics' => true as an extra parameter and therefore adds it to the end of the URL.

In your core.php file add prefix array politics

Configure::write(
    'Routing.prefixes', 
     array(
         'admin', 
         'assesor', 
         'resource', 
         'contacts', 
         'politics' // Agregamos el prefijo 'politics'
     )
);
    
answered by 20.04.2018 / 17:30
source