I've tried to include the service-menu-block into the twig file of the sidebar, which is loaded in category-pages, but for some reason the this doesn't work. its the same code, thats works in the footer section. If I write some static html in there it shows, but but the pages from the menu aren't listed. could somebody help out?
This is the code from the service menu:
{% sw_include '@Storefront/storefront/layout/navigation/my-service-menu.html.twig'%}
CodePudding user response:
The footer navigation content, i assume thats the content you want to display inside your category page sidebar, is only loaded during the FooterPageletLoader
and added during the GenericPageLoader
to the page.footer
variable for twig.
You can test that by adding {{ dump(page.footer) }}
to the template where you wanted to include the service menu. If the dump is empty, your current page is not using the GenericPageLoader
or does not have access to the data. If the dump is not empty, the required data for the template might need to be passed differently. For example:
{% sw_include '@Storefront/storefront/layout/navigation/my-service-menu.html.twig'' with {
data: page.test
} %}
Shopwares GenericPageLoader can be injected if its missing from your Controller/PageLoader. In my example, MyPageStruct extends Struct and provides just one function.
public function __construct(
private readonly GenericPageLoaderInterface $genericLoader
) { }
public function load(Request $request, SalesChannelContext $salesChannelContext): MyPageStruct
{
$page = $this->genericLoader->load($request, $salesChannelContext);
$page = MyPageStruct::createFrom($page);
$page->setDataFunction();
return $page;
}
Complete examples can be found in shopwares core code: Shopware\Storefront\Page\Account\Login\AccountLoginPageLoader