Magento – magento 2 widget layout update : specified pages section not showing all cms pages

layoutmagento2widgets

I have created widget that i want to show on sidebar of about us and our company page, but in widget layout update >> specified pages section i can not find any option to see any option of My Cms About us and CMS Company page ,

Is there any fix to it

Best Answer

It's definitely a bug or i would say more likely an overlook from magento 2 team. Magento 2.2.5 When you create the cms page you would expect the page types will get updated automatically but they are not.

I have't inspected this in depth however one static way to go around this is to create in a custom module etc/frontend/page_types.xml and add your page layout like this

<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_types.xsd">
<type id="cms_page_view_id_about-us" label="CMS Pages (About us)"/>

Id is your handle of the page. You can get all handles by enabling developer tools in admin or in /Applications/MAMP/htdocs/appliance.loc/vendor/magento/framework/View/Model/Layout/Merge.php in addHandle method add in foreach echo $name and in else statement add echo $handleName.

When i catch time ill investigate how to make this dynamically but from what I have seen their code is not dynamic either for now.

I can understand from one side why it has been done like this to use page layouts but the issue is page layouts also do not work and is a confirmed bug https://github.com/magento/magento2/issues/9537

Related Topic