简体   繁体   中英

Placing static block before catalog product list widget on home page - Magento 2.2

I'm developing eCommerce site using Magento latest version. I created static block in admin area.

Block identifier - middle-links-block

Then I added this block to home page using given tools.

 {{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="26" }}  

Also I added catalog product list widget to the home page. In the widget I selected Main content area option as position of the widget. And then I wanted to move middle-links-block before the widget because its always after the product list widget. I tried below code in layout update section,

 <referenceContainer name="main.content">
          <block class="Magento\Cms\Block\Block" name="middle-links-block" 
          before="block-products-list">
            <arguments>
               <argument name="block_id" xsi:type="string">middle-links-block</argument>
            </arguments>
          </block>
        </referenceContainer>  

and html of widget,

<div class="block widget block-products-list grid">
                <div class="block-content">
            <!-- new_products_content_widget_grid-->            <div class="products-grid grid">
                <ol class="product-items widget-product-grid">

But nothing will affect to the page. I cleared cache and and redeployed as well.I can't figure out what is the issue. Please help.

I found the issue. We don't have to put block in both places and we can use widget instead. Add static block to it. So then we can position widget as preferred.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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