[英]How can i create category page link in cakephp?
How can i create category page link in cakephp? 如何在cakephp中创建类别页面链接?
<?php if(count($cat)>0): foreach($cat as $cat_item): ?>
<li>
<a href="<?php Router::url('/', true); ?>category/<?php echo $cat_item['CatModel']['caturl']; ?>">
<?php echo $cat_item['CatModel']["catname"]; ?></a>
</li>
<?php endforeach; else: ?>
<p class="no-record"></p>
<?php endif; ?>
You need to do 4 steps : 您需要执行4个步骤:
If you wish to use the HTML helper you can use this. 如果您希望使用HTML帮助器,则可以使用它。
<li>
<?= $this->Html->link(__($cat_item['CatModel']['catname']), ['controller' => 'Categories', 'action' => 'view', $cat_item['CatModel']['id']]); ?>
</li>
Assuming your category controller is called "CategoriesController.php", and is located in src/Controller 假设您的类别控制器称为“ CategoriesController.php”,并且位于src / Controller中
In general, you can use the cake client from the command line to generate models/controllers/views if you follow the cake schema naming convention. 通常,如果您遵循Cake模式命名约定,则可以从命令行使用Cake客户端生成模型/控制器/视图。
bin/cake bake template categories
垃圾桶/蛋糕烘烤模板类别
If you wish to see the cake way of doing things. 如果您希望看到做事的蛋糕方式。 It will generate your view.
它将生成您的视图。 Also for more information on the HTML helper check out the CookBook .
有关HTML帮助程序的更多信息,请查看CookBook 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.