简体   繁体   中英

Linking static page in CakePhp

I just want to create a static page to my website and link that page to the home page button. I managed to create the page but when I link it like this <li><a href="about">About</a></li> following error appears.

Missing Controller
Error: AboutController could not be found.

How should I put the link between home and about page?

PS. In every example on web they have shown how to create the static page and put route. But no one has mentioned how to go to that page without manually typing "/pages/about" in the url. May be it is a simple thing. But what I'm missing is that. Please help.

You can use the Html Helper in this way:

<li>
  <?php echo $this->Html->link('About',array('controller'=>'pages','action'=>'display','about')) ?>
</li>

Or to get just the url:

<li>
  <a href="<?php echo $this->Html->url(array('controller'=>'pages','action'=>'display','about')) ?>"> Home </a>
</li>

Check out the Routing documentation

You can use

Router::connect(
    '/about',
    array('controller' => 'pages', 'action' => 'display', 'about')
);

to connect /about to your static page.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM