简体   繁体   English

类别列表页面的类别描述

[英]Category description to category list page

How to get category descrption to category list page which lists subcategories.如何获取列出子类别的类别列表页面的类别描述。 For example I have Shoes-page which lists all subcategorys:例如,我有列出所有子类别的鞋类页面:

Nike, Adidas, Puma

Now I want to have description text on this Shoes-page like:现在我想在这个鞋子页面上有描述文字,比如:

Nike - This is description text.
Adidas - This is description text2.
Puma - This is description text3.

At this moment description text is shown inside of Nike page, but how to get it to Shoes-page?此时描述文本显示耐克页面内,但如何将其转到鞋页面?

I see in category.tpl file thise:我在 category.tpl 文件中看到:

<?php if ($description) { ?>
<?php echo $description; ?>
<?php } ?>

Which handels description, but do I need to place it somewhere else or what need to be done?哪个handels描述,但我需要把它放在其他地方还是需要做什么?

First you need to pass subcategories' description from controller to tpl file,首先,您需要将子类别的描述从控制器传递到 tpl 文件,

in catalog\\controller\\product\\category.phpcatalog\\controller\\product\\category.php

find

'name'  => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),

just after this line add the following line在此行之后添加以下行

'description' => strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')),

Now in your tpl file that is catalog\\view\\theme\\your_theme\\template\\product\\category.tpl现在在您的 tpl 文件中,即catalog\\view\\theme\\your_theme\\template\\product\\category.tpl

you have to add <?php echo $category['description'];?> inside the following loop您必须在以下循环中添加<?php echo $category['description'];?>

<?php foreach ($categories as $category) { ?>
  <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
<?php } ?>

PS Edit your question to inital one, it was more explanatory than it is now PS将您的问题编辑为inital one,它比现在更具解释性

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM