在网站文章列表中显示类别树 Odoo

Display in the list of website articles the tree of categories Odoo

我想在网站文章列表中显示类别树 我尝试使用此源代码,但它只显示了最后的类别

<div class="row">
            <div class="col-sm-12">
                <ol class="breadcrumb">
 <li t-if="category"><a t-att-href="keep('/shop',category=0)" t-field="category.name"/></li>

 <li t-if="category">
<a t-att-href="keep('/shop/category/' + slug(category), category=0)"
                   t-field="category.name"/>
</li>  

                </ol>

                <ol>
  <li t-if="category.child_id" t-attf-class="text-primary fa #{'fa-chevron-down' if category.id in parent_category_ids else 'fa-chevron-right'}">
      <a t-att-href="keep('/shop/category/' + slug(category), category=0)" t-field="category.name"></a>

  </li>


                </ol>


            </div>


          </div>

我想要像图片一样的结果

我在这个模块中找到了解决方案

https://www.odoo.com/apps/modules/10.0/website_breadcrumb/

您可以在网站模块 xml 文件中添加此模板

这是真实代码 XML

    <template id="breadcrumb" name="Breadcrumb snippet">
        <!-- Know if current page is in a menu item -->
        <t t-set="bc_item"
           t-value="request.env['website.menu']
                    .search([('url', '=', request.httprequest.path)], limit=1)"/>
    
        <!-- If so, create the breadcrumbs -->
        <ol t-if="bc_item" class="breadcrumb">
            <!-- Parents -->
            <t t-foreach="bc_item.get_parents(True)" t-as="step">
                <li t-if="step.url or step_first">
                    <a t-att-href="step.url or (step_first and '/')">
                        <t t-if="step_first and not step.url">
                            Home
                        </t>
                        <t t-if="not step_first and step.url">
                           <t t-esc="step.name_get()[0][1]"/>
                       </t>
                    </a>
                </li>
            </t>
    
            <!-- Current -->
            <li class="active" t-esc="bc_item.name_get()[0][1]"/>
        </ol>
    </template>

谢谢