1

我想在 Shopware 6 中创建一个自定义页面,其中包括侧边栏过滤器块。1.st 我使用加载 index.html.twig 的自定义路由创建了控制器。索引文件从扩展自 base.html.twig 的默认店面索引文件扩展而来。在我的 index.html.twig 文件中,我包含了文件 @Storefront/storefront/block/cms-block-sidebar-filter.html.twig 但这个文件在我的 tpl 中是空的。我认为这是重复使用过滤器的错误方法。你有什么办法弄清楚吗?

谢谢你的时间

  1. 带有自定义路由的控制器

    $page = $this->genericPageLoader->load($request, $scontext);
    
    return $this->renderStorefront('@DRGeolocation\storefront\index.html.twig', [
         'page' => $page,
         'range' => 15,
         'sellers'=> $sellers,
         'config' => $config['config']
         ,
         'block'=> $element
     ]);
    

index.html.twig

{% sw_extends '@Storefront/storefront/page/content/index.html.twig' %}
  {% block page_content_blocks %}
  ...
  {% sw_include ('@Storefront/storefront/block/cms-block-sidebar-filter.html.twig') %}
  ....

cms-block-sidebar-filter.html.twig

{% block block_sidebar_filter %}
{% set element = block.slots.getSlot('content') %}
{% set columns = 1 %}

<div class="col-12" data-cms-element-id="{{ element.id }}">
    {% block block_sidebar_filter_inner %}
        {% sw_include "@Storefront/storefront/element/cms-element-" ~ element.type ~ ".html.twig" ignore missing %}
    {% endblock %}
</div>
{% endblock %}

//result: <div class="col-12" data-cms-element-id=""></div>
4

0 回答 0