I am working with CakePHP 2.9 on a math-quiz application. My status with CakePHP is 'beginner'.
I would like to create a link to a high-scores page in app/Layouts/default.ctp. Therefore, I edited the default link to the CakePHp website into
<li><a target="_blank" href=".<?php $this->Getscores->getscores();?>.">High scores</a></li>
.
But as far as now, the only thing I observe when clicking the link is a redirection to the landing page, no stack trace or error messages available.
This is what I have done as sofar:
GetscoresController.php
in the directory app/Controller/
GetscoresController.php
to GetscoresController
getscores()
inside the class GetscoresController
To reduce complexity I only create a variable $myvar
assigned to the value "hiscores" in this function: $myvar='hiscores'; $this->set(compact('myvar');
$myvar='hiscores'; $this->set(compact('myvar');
Created a getscores.ctp in app/View/Getscores/ with only the code <?php echo $this->myvar; ?>
<?php echo $this->myvar; ?>
Created an extra route in app/Config/routes.php: Router::connect('/', array('controller' => 'getscores', 'action' => 'index', 'getscores'));
I am wondering why the steps I took, obviously were not satisfying to get the link working. Can anyone point me out what I have done wrong and help me to set the link correct?
Why not using html helper?
<li>
<?= $this->Html->link('High scores', [
'controller'=> 'Getscores',
'action' => 'getscores',
$myvar // <-------------------
],
['_target' => 'blank'] ); ?>
</li>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.