1

I want to move the page main title on the category list page into custom div and also include the product_list_toolbar into that div.

The problem I face is that I can not simply move the product_list_toolbar, because that is not allowed in M2.

Is there a way to create a div inside the /app/design/frontend/theme/theme/Magento_Catalog/templates/product/list.phtml and move the page.main.title into that div?

So something like this in the category list template:

<div class="category-page-header" id="category.page.header">
    <?= $block->getToolbarHtml() ?>
</div>

And then inside the catalog_catagory_view.xml file:

<move element="page.main.title" destination="category.page.header" before="-"/>

Any ideas how to create this div around both elements?

I can solve it by adding the following into the /app/design/frontend/theme/theme/Magento_Catalog/templates/product/list.phtml file.

<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');?> 

<?= $category->getName() ?>

Will this be the best and only solution?

0

Your Answer

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

Browse other questions tagged or ask your own question.