简体   繁体   English

在CakePhp中链接静态页面

[英]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连接到您的静态页面。

CAKEPHP:链接整体<div></div><div id="text_translate"><p>我可以查看 Notes 表中的特定字段。</p><pre> echo "&lt;div id='notescover'&gt;"; echo "&lt;p class='text'&gt;"; echo $viewnotes['Note']['notes']; echo "&lt;/p&gt;"; echo "&lt;/div&gt;";</pre><p> 我已将 Comment 链接到特定的注释 URL,例如 /note/view/IDofNote</p><pre> echo $this-&gt;Html-&gt;link('Comment', array( 'controller'=&gt;'notes', 'action'=&gt;'view',$viewnotes['Note']['id']), array('class'=&gt; 'light_blue'));</pre><p> 我想删除此链接并将相同的操作链接到上面的 div 标记。 我能够像这样链接字段内的文本</p><pre>echo $this-&gt;Html-&gt;link($viewnotes['Note']['notes'], array( 'controller'=&gt;'notes', 'action'=&gt;'view',$viewnotes['Note']['id']), array('class'=&gt; 'light_blue'));</pre><p> 但我想要链接整个盒子。</p><p> 我怎样才能做到这一点?</p></div> - CAKEPHP: Linking the whole <div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CakePHP中的静态html页面 - static html page in CakePHP 静态WordPress页面链接到帖子 - Static wordpress page linking to posts Yii-链接到给定模型ID的静态页面 - Yii - linking to static page of a given model id 在CakePHP中链接静态页面而不附加控制器 - Link for static page in CakePHP without appending the controller 如何用CakePHP密码保护静态页面? - How to password protect a static page in CakePHP? Cakephp 2.4 + 静态页面路由 URL - Cakephp 2.4 + Static Page Rounting URL 允许静态页面通过CakePHP登录 - Allowing a static page get through login in cakePHP CakePHP hasAndBelongsToMany没有按预期链接 - CakePHP hasAndBelongsToMany not linking as expected CAKEPHP:链接整体<div></div><div id="text_translate"><p>我可以查看 Notes 表中的特定字段。</p><pre> echo "&lt;div id='notescover'&gt;"; echo "&lt;p class='text'&gt;"; echo $viewnotes['Note']['notes']; echo "&lt;/p&gt;"; echo "&lt;/div&gt;";</pre><p> 我已将 Comment 链接到特定的注释 URL,例如 /note/view/IDofNote</p><pre> echo $this-&gt;Html-&gt;link('Comment', array( 'controller'=&gt;'notes', 'action'=&gt;'view',$viewnotes['Note']['id']), array('class'=&gt; 'light_blue'));</pre><p> 我想删除此链接并将相同的操作链接到上面的 div 标记。 我能够像这样链接字段内的文本</p><pre>echo $this-&gt;Html-&gt;link($viewnotes['Note']['notes'], array( 'controller'=&gt;'notes', 'action'=&gt;'view',$viewnotes['Note']['id']), array('class'=&gt; 'light_blue'));</pre><p> 但我想要链接整个盒子。</p><p> 我怎样才能做到这一点?</p></div> - CAKEPHP: Linking the whole <div> 在CakePHP中链接多个到多个关联 - Linking Many to Many associations in CakePHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM