面包屑中的 CakePHP 内容计数
CakePHP content count in breadcrumbs
我正在使用 cakephp 面包屑助手,我有面包屑模板
$this->Breadcrumbs->setTemplates([
'wrapper' => '<nav aria-label="breadcrumb">
<ol {{attrs}}> {{content}}
</ol>
</nav>',
'item' => '<li {{attrs}}>
<a itemprop="item" href="{{url}}"{{innerAttrs}}>
<span>{{title}}</span></a>
<meta content={{count}}>
</li>{{separator}}',
]);
在元内容中我需要像 1,2,3...
我现在的输出
<nav>
<ol>
<li>
<a href=""></a>
<meta itemprop = "position" content>
</li>
</ol>
</nav>
期望输出:
<nav>
<ol>
<li>
<a href=""></a>
<meta itemprop = "position" content=1> <-- desire output
</li>
</ol>
</nav>
我可以在 JavaScript 之前完成。是否可以使用 cakephp 面包屑助手在元内容 (<meta content={{count}}
>) 中动态放置列表计数?
CakePHP Book: Customizing the Output
$this->Breadcrumbs->add(
'Products',
['controller' => 'products', 'action' => 'index'],
[
'class' => 'products-crumb',
'data-foo' => 'bar',
'count' => 1 //<----------------------------
'innerAttrs' => [
'class' => 'inner-products-crumb',
'id' => 'the-products-crumb'
]
]
);
// Based on the default template, this will render the following HTML:
<li class="products-crumb" data-foo="bar">
<a href="/products/index" class="inner-products-crumb" id="the-products-crumb">Products</a>
<meta itemprop = "position" content=1> <-- desire output
</li>
我正在使用 cakephp 面包屑助手,我有面包屑模板
$this->Breadcrumbs->setTemplates([
'wrapper' => '<nav aria-label="breadcrumb">
<ol {{attrs}}> {{content}}
</ol>
</nav>',
'item' => '<li {{attrs}}>
<a itemprop="item" href="{{url}}"{{innerAttrs}}>
<span>{{title}}</span></a>
<meta content={{count}}>
</li>{{separator}}',
]);
在元内容中我需要像 1,2,3...
我现在的输出
<nav>
<ol>
<li>
<a href=""></a>
<meta itemprop = "position" content>
</li>
</ol>
</nav>
期望输出:
<nav>
<ol>
<li>
<a href=""></a>
<meta itemprop = "position" content=1> <-- desire output
</li>
</ol>
</nav>
我可以在 JavaScript 之前完成。是否可以使用 cakephp 面包屑助手在元内容 (<meta content={{count}}
>) 中动态放置列表计数?
CakePHP Book: Customizing the Output
$this->Breadcrumbs->add(
'Products',
['controller' => 'products', 'action' => 'index'],
[
'class' => 'products-crumb',
'data-foo' => 'bar',
'count' => 1 //<----------------------------
'innerAttrs' => [
'class' => 'inner-products-crumb',
'id' => 'the-products-crumb'
]
]
);
// Based on the default template, this will render the following HTML:
<li class="products-crumb" data-foo="bar">
<a href="/products/index" class="inner-products-crumb" id="the-products-crumb">Products</a>
<meta itemprop = "position" content=1> <-- desire output
</li>