0

I've search for some answers to this but unfortunately I can't seem to find anything. I would really appreciate some help about this.

I have created a custom container using XML in 'catalog_category_view.xml' file and then move other blocks (elements) in there. The idea is to display the container on the product listing page (category page) just next to the product grid. However, I find difficulties with the placement for my new container. I would like to move the container next to the products into the products grid. Is it possible to insert a custom container inside the products listing (ol > li) as a first element.

My idea is to have a grid which has 4 products per row (25% per product) and to start with custom section. So the 4 columns grid and rows would look like this:

50% custom container + 25% product + 25% product

25% product + 25% product + 25% product + 25% product

25% product + 25% product + 25% product + 25% product

Right now I have added the custom container just before the product listing section using XML and then using simple jQueary move the container into the product listing using the following code:

$('.custom-container').detach().prependTo('ol.product-items');

I understand that this is not a perfect solution and that's why I am asking here, any help would be appreciated. Thank you in advance!

Vrajesh Patel
2,0122 gold badges14 silver badges32 bronze badges
asked Feb 4, 2020 at 9:03

1 Answer 1

0

It doesn't possible move container in block.. Becuase Container is grouping of blocks. I think it is better that using block. You can render child block in template using getChildHtml method of Block class.

ref) https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-instructions.html ref) https://www.simicart.com/blog/magento-getchildhtml/

answered Feb 4, 2020 at 9:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.