[英]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. 我设法创建了页面,但是当我像这样链接它时,会出现以下错误: <li><a href="about">About</a></li>
。
Missing Controller 缺少控制器
Error: AboutController could not be found. 错误:找不到AboutController。
How should I put the link between home and about page? 我应该如何放置首页和关于页面之间的链接?
PS. 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. 但是没有人提到如何在不手动在URL中键入“ / pages / about”的情况下转到该页面。 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: 您可以通过以下方式使用Html帮助器:
<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. 将/about
连接到您的静态页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.