Kohana 中的面包屑导航错误
我正在使用 Kohana 框架在我的应用程序上实现面包屑 https://github.com/RaymondCrandall/kohana-breadcrumbs< /a>
我有一个类别部分,内部有许多其他子类别等等。一个名为 Category.php 的控制器有两个操作: 1.index($cat)(当我单击每个类别直到到达最后一个子类别时调用) 2.category($cat)(当我单击最后一个子类别时调用,即在叶节点上)
我将代码写入两个操作的方式是:
Breadcrumbs::add(Breadcrumb::factory()->set_title("Home")->set_url(url::site()));
Breadcrumbs::add(Breadcrumb::factory()->set_title("Categories")->set_url(url::site('categories')));
if($cat != NUll) {
Breadcrumbs::add(Breadcrumb::factory()->set_title($cat)->set_url(url::site('categories/' .$cat )));
}
$actual = Breadcrumbs::get();
$view->breadcrumbs = $actual;
问题是它只显示了三个级别。我怎样才能将其扩展到4级或更高。 例如。首页>类别>文具>连衣裙。如何保存之前的 $actual 值?
因此,当我单击裙子时,会调用索引操作并将我的数组替换为 home>category>dress 因为参数 '$cat= dress'。
I am implementing breadcrumbs on my application using Kohana framework using https://github.com/RaymondCrandall/kohana-breadcrumbs
I have a Category section which internally has many other sub categories n so on. One controller called Category.php having two action:
1. index($cat) (called when I click on each category until it reaches the last sub category)
2. category($cat) (called when I click on last sub category i.e. on leaf node )
The way I wrote my code into both action is:
Breadcrumbs::add(Breadcrumb::factory()->set_title("Home")->set_url(url::site()));
Breadcrumbs::add(Breadcrumb::factory()->set_title("Categories")->set_url(url::site('categories')));
if($cat != NUll) {
Breadcrumbs::add(Breadcrumb::factory()->set_title($cat)->set_url(url::site('categories/' .$cat )));
}
$actual = Breadcrumbs::get();
$view->breadcrumbs = $actual;
The problem is it shows me only three levels. How can I extend it to 4th level or more.
Eg. home>category>stationary>dress. How can I save my previous values of $actual?
So when I click on dress, index action is called and replaces my array with
home>category>dress since parameter '$cat= dress'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这与提到的插件没有太大关系。
您只是使用类别名称字符串,一个简单的字符串甚至不知道什么是类别,更不知道它的名称是什么,以及层次结构。
我看到三个选项:
I don't think this is much related to the mentioned plugin.
You are just using the category name string, a simple string doesn't even know what is a category, event less what is it's name, and hierarchy.
I see three options: