Hello!
How can i add a custom block right after the main navigation? I am extending the Luma theme.
I created the block and i can add it to static page, but not to a layout file.
catalog.topnav is the block you need. You must put the block that you want to display in your default.xml.
<block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav" template="html/topmenu.phtml" ttl="3600" before="-"/>
Try the following and let me know if that helps:
<referenceContainer name="page.top"> <block class="Magento\Cms\Block\Block" name="my.custom.block" after="catalog.topnav"> <arguments> <argument name="block_id" xsi:type="string">Customer-block-id</argument> </arguments> </block> </referenceContainer>
Thank you, but this removes the topnav completly. This is my layout
<?xml version="1.0"?> <!-- /** * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="header.panel"> <block class="Magento\Framework\View\Element\Html\Links" name="header.links"> <arguments> <argument name="css_class" xsi:type="string">header links</argument> </arguments> </block> </referenceContainer> <block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav" template="html/topmenu.phtml" ttl="3600" before="-"/> <referenceContainer name="page.top"> <block class="Acty\Slider\Block\Slider" name="my.custom.block" after="catalog.topnav"> <arguments> <argument name="block_id" xsi:type="string">Customer-block-id</argument> </arguments> </block> </referenceContainer> </body> </page>
Just remove <referenceContainer name="page.top"> section and try again. Also, try redeploying the static content as well.
Sorry, this is not working