我正在制作一个由其他人定制的主题。
所以在
/websitename.com/app/design/frontend/rwd/ysv/template/page/category.phtml
被创建被调用。当我点击任何类别或子类别时。
当用户在类别/子类别页面上时,我想显示面包屑。
echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();
This will not help in my case i think.
System > Configuration > General > Web > Default Pages > Show Breadcrumbs for CMS Pages. is set to YES.
Update:
<catalog_category_default translate="label">
<label>Catalog Category (Non-Anchor)</label>
.........
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/> <!-- Addedd -->
和
<catalog_category_layered translate="label">
<label>Catalog Category (Anchor)</label>
.....................
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="core/text_list" name="product_list.name.after" as="name.after" />
<block type="core/text_list" name="product_list.after" as="after" />
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/> <!-- Addedd -->
在
page.xml
<!-- category (default) -->
<catalog_category_default>
<reference name="root">
<action method="setTemplate"><template>page/category.phtml</template></action>
</reference>
</catalog_category_default>
在
category.phtml
<?php echo $this->getChildHtml('head'); ?>
<?php echo $this->getChildHtml('after_body_start'); ?>
<!-- global messages -->
<?php echo $this->getChildHtml('global_notices'); ?>
<!-- header -->
<?php echo $this->getChildHtml('header'); ?>
<!-- content -->
<?php echo $this->getChildHtml('content'); ?>
<!-- footer -->
<?php echo $this->getChildHtml('footer'); ?>
<?php echo $this->getChildHtml('before_body_end'); ?>
<?php echo $this->getAbsoluteFooter(); ?>
我可以在自定义模块或任何其他方法中根据当前网址创建动态面包屑吗? 请建议.
最新回答
- 2019-12-51 #
- 2019-12-52 #
对于类别只需在wyzwyz中添加以下代码即可 对于
catalog.xml
和catalog_category_layered
布局句柄catalog_category_default
对于自定义页面,您可以关注@ Dinesh的答案
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
如果您想动态设置名称和网址,那么除了Dinesh的答案,您还可以使用帮助方法.例如: -Update:
在你的辅助函数中
<action method="addCrumb"> <!-- First breadcrumbs name --> <name helper="yourmodule/getName"/> <!-- add label, title, link --> <params helper="yourmodule/getHomeUrl" /> </action>
在
public function getHomeUrl() { return array( "label" => $this->__('Home'), "title" => $this->__('Home'), "link" => custom_url ); } public function getName() { return $name; }
中添加以下代码 在category.phtml
之后global_notices
<?php echo $this->getChildHtml('breadcrumbs') ?></div>
您可以使用xml将自定义页面添加到面包屑中。 在主题的 local.xml中添加以下xml代码 文件。