I have little Confused about page_types.xml. Why we need this? and How this Useful for us? I researched about page_types.xml in this document Still not get exact answer.

I saw some page_types in magento Calalog_module:

<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_types.xsd">
    <type id="catalog_category_view" label="Catalog Category"/>
    <type id="catalog_product_compare_index" label="Catalog Product Compare List"/>
    <type id="catalog_product_gallery" label="Catalog Product Image Gallery Popup"/>
    <type id="catalog_product_view" label="Catalog Product View (Any)"/>

I dont know, where to use this types.

Suggest me Why we need this? and How to Usefull for us?

  • 1
    Need some input on this. please help us to clear this
    – Shivam
    Apr 26, 2018 at 13:45

1 Answer 1


Magento define each page have it own type. You can see how it implement in admin widget inside Content > Widget. This module allow you add widget block to any where in your page. If you want add to your specific place. Create your own page type and layout and add it to there.


     * Retrieve available page types
     * @return \Magento\Framework\DataObject[]
    public function getPageTypes()
        return $this->_pageTypes;


     * Add necessary options
     * @return \Magento\Framework\View\Element\AbstractBlock
    protected function _beforeToHtml()
        if (!$this->getOptions()) {
            $this->addOption('', __('-- Please Select --'));
            $pageTypes = $this->_config->getPageTypes();
        return parent::_beforeToHtml();

That mean you can create your own page with own page type and ability add to layout handle you want

Example: create your own define page type: /etc/frontend/example_page_types.xml

<example_page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type id="your-route_action_index" label="Your custom Pages"/>

type id is corresponding to layout handle define your page when controller call

  • page have it own type? I am not clear with this. Can you please help me to understand.
    – Shivam
    Apr 26, 2018 at 13:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.