How to call a CMS page in another CMS page in magento 2












0















I have two CMS pages in magento 2 . I want to call one cms page to another cms page.



anyone can help me.










share|improve this question

























  • I don't think it is possible, for these types of task we use static block and call static block in other cms pages

    – Shoaib Munir
    16 hours ago











  • actually i have used layout xml in another cms. so i can not use block instead of pages

    – Sarvesh Tiwari
    16 hours ago
















0















I have two CMS pages in magento 2 . I want to call one cms page to another cms page.



anyone can help me.










share|improve this question

























  • I don't think it is possible, for these types of task we use static block and call static block in other cms pages

    – Shoaib Munir
    16 hours ago











  • actually i have used layout xml in another cms. so i can not use block instead of pages

    – Sarvesh Tiwari
    16 hours ago














0












0








0








I have two CMS pages in magento 2 . I want to call one cms page to another cms page.



anyone can help me.










share|improve this question
















I have two CMS pages in magento 2 . I want to call one cms page to another cms page.



anyone can help me.







magento2 cms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 9 mins ago









adi maheshwary

92




92










asked 16 hours ago









Sarvesh TiwariSarvesh Tiwari

369322




369322













  • I don't think it is possible, for these types of task we use static block and call static block in other cms pages

    – Shoaib Munir
    16 hours ago











  • actually i have used layout xml in another cms. so i can not use block instead of pages

    – Sarvesh Tiwari
    16 hours ago



















  • I don't think it is possible, for these types of task we use static block and call static block in other cms pages

    – Shoaib Munir
    16 hours ago











  • actually i have used layout xml in another cms. so i can not use block instead of pages

    – Sarvesh Tiwari
    16 hours ago

















I don't think it is possible, for these types of task we use static block and call static block in other cms pages

– Shoaib Munir
16 hours ago





I don't think it is possible, for these types of task we use static block and call static block in other cms pages

– Shoaib Munir
16 hours ago













actually i have used layout xml in another cms. so i can not use block instead of pages

– Sarvesh Tiwari
16 hours ago





actually i have used layout xml in another cms. so i can not use block instead of pages

– Sarvesh Tiwari
16 hours ago










1 Answer
1






active

oldest

votes


















0














Add following xml in Design -> Layout Update XML



<referenceContainer name="content">
<block class="SRMagentoCommunityBlockPage" name="another_cms_page" after="cms_page">
<arguments>
<argument name="page_id" xsi:type="number">7</argument>
</arguments>
</block>
</referenceContainer>


enter image description here



Now create app/code/SR/MagentoCommunity/Block/Page.php



<?php
namespace SRMagentoCommunityBlock;

use MagentoCmsApiPageRepositoryInterface;

class Page extends MagentoFrameworkViewElementAbstractBlock implements
MagentoFrameworkDataObjectIdentityInterface
{
/**
* @var MagentoCmsModelTemplateFilterProvider
*/
private $filterProvider;

/**
* @var PageRepositoryInterface
*/
private $pageRepository;

/**
* Page constructor.
*
* @param MagentoFrameworkViewElementContext $context
* @param MagentoCmsModelTemplateFilterProvider $filterProvider
* @param PageRepositoryInterface $pageRepository
* @param array $data
*/
public function __construct(
MagentoFrameworkViewElementContext $context,
MagentoCmsModelTemplateFilterProvider $filterProvider,
PageRepositoryInterface $pageRepository,
array $data =
) {
parent::__construct($context, $data);
$this->filterProvider = $filterProvider;
$this->pageRepository = $pageRepository;
}

/**
* Prepare global layout
*
* @return $this
*/
protected function _prepareLayout()
{
$pageId = $this->getPageId();
$cmsPage = $this->pageRepository->getById($pageId);
$this->setPage($cmsPage);
return parent::_prepareLayout();
}

/**
* Prepare HTML content
*
* @return string
*/
protected function _toHtml()
{
$html = $this->filterProvider->getPageFilter()->filter($this->getPage()->getContent());
return $html;
}

/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
{
return [MagentoCmsModelPage::CACHE_TAG . '_' . $this->getPage()->getId()];
}
}





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264670%2fhow-to-call-a-cms-page-in-another-cms-page-in-magento-2%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Add following xml in Design -> Layout Update XML



    <referenceContainer name="content">
    <block class="SRMagentoCommunityBlockPage" name="another_cms_page" after="cms_page">
    <arguments>
    <argument name="page_id" xsi:type="number">7</argument>
    </arguments>
    </block>
    </referenceContainer>


    enter image description here



    Now create app/code/SR/MagentoCommunity/Block/Page.php



    <?php
    namespace SRMagentoCommunityBlock;

    use MagentoCmsApiPageRepositoryInterface;

    class Page extends MagentoFrameworkViewElementAbstractBlock implements
    MagentoFrameworkDataObjectIdentityInterface
    {
    /**
    * @var MagentoCmsModelTemplateFilterProvider
    */
    private $filterProvider;

    /**
    * @var PageRepositoryInterface
    */
    private $pageRepository;

    /**
    * Page constructor.
    *
    * @param MagentoFrameworkViewElementContext $context
    * @param MagentoCmsModelTemplateFilterProvider $filterProvider
    * @param PageRepositoryInterface $pageRepository
    * @param array $data
    */
    public function __construct(
    MagentoFrameworkViewElementContext $context,
    MagentoCmsModelTemplateFilterProvider $filterProvider,
    PageRepositoryInterface $pageRepository,
    array $data =
    ) {
    parent::__construct($context, $data);
    $this->filterProvider = $filterProvider;
    $this->pageRepository = $pageRepository;
    }

    /**
    * Prepare global layout
    *
    * @return $this
    */
    protected function _prepareLayout()
    {
    $pageId = $this->getPageId();
    $cmsPage = $this->pageRepository->getById($pageId);
    $this->setPage($cmsPage);
    return parent::_prepareLayout();
    }

    /**
    * Prepare HTML content
    *
    * @return string
    */
    protected function _toHtml()
    {
    $html = $this->filterProvider->getPageFilter()->filter($this->getPage()->getContent());
    return $html;
    }

    /**
    * Return identifiers for produced content
    *
    * @return array
    */
    public function getIdentities()
    {
    return [MagentoCmsModelPage::CACHE_TAG . '_' . $this->getPage()->getId()];
    }
    }





    share|improve this answer




























      0














      Add following xml in Design -> Layout Update XML



      <referenceContainer name="content">
      <block class="SRMagentoCommunityBlockPage" name="another_cms_page" after="cms_page">
      <arguments>
      <argument name="page_id" xsi:type="number">7</argument>
      </arguments>
      </block>
      </referenceContainer>


      enter image description here



      Now create app/code/SR/MagentoCommunity/Block/Page.php



      <?php
      namespace SRMagentoCommunityBlock;

      use MagentoCmsApiPageRepositoryInterface;

      class Page extends MagentoFrameworkViewElementAbstractBlock implements
      MagentoFrameworkDataObjectIdentityInterface
      {
      /**
      * @var MagentoCmsModelTemplateFilterProvider
      */
      private $filterProvider;

      /**
      * @var PageRepositoryInterface
      */
      private $pageRepository;

      /**
      * Page constructor.
      *
      * @param MagentoFrameworkViewElementContext $context
      * @param MagentoCmsModelTemplateFilterProvider $filterProvider
      * @param PageRepositoryInterface $pageRepository
      * @param array $data
      */
      public function __construct(
      MagentoFrameworkViewElementContext $context,
      MagentoCmsModelTemplateFilterProvider $filterProvider,
      PageRepositoryInterface $pageRepository,
      array $data =
      ) {
      parent::__construct($context, $data);
      $this->filterProvider = $filterProvider;
      $this->pageRepository = $pageRepository;
      }

      /**
      * Prepare global layout
      *
      * @return $this
      */
      protected function _prepareLayout()
      {
      $pageId = $this->getPageId();
      $cmsPage = $this->pageRepository->getById($pageId);
      $this->setPage($cmsPage);
      return parent::_prepareLayout();
      }

      /**
      * Prepare HTML content
      *
      * @return string
      */
      protected function _toHtml()
      {
      $html = $this->filterProvider->getPageFilter()->filter($this->getPage()->getContent());
      return $html;
      }

      /**
      * Return identifiers for produced content
      *
      * @return array
      */
      public function getIdentities()
      {
      return [MagentoCmsModelPage::CACHE_TAG . '_' . $this->getPage()->getId()];
      }
      }





      share|improve this answer


























        0












        0








        0







        Add following xml in Design -> Layout Update XML



        <referenceContainer name="content">
        <block class="SRMagentoCommunityBlockPage" name="another_cms_page" after="cms_page">
        <arguments>
        <argument name="page_id" xsi:type="number">7</argument>
        </arguments>
        </block>
        </referenceContainer>


        enter image description here



        Now create app/code/SR/MagentoCommunity/Block/Page.php



        <?php
        namespace SRMagentoCommunityBlock;

        use MagentoCmsApiPageRepositoryInterface;

        class Page extends MagentoFrameworkViewElementAbstractBlock implements
        MagentoFrameworkDataObjectIdentityInterface
        {
        /**
        * @var MagentoCmsModelTemplateFilterProvider
        */
        private $filterProvider;

        /**
        * @var PageRepositoryInterface
        */
        private $pageRepository;

        /**
        * Page constructor.
        *
        * @param MagentoFrameworkViewElementContext $context
        * @param MagentoCmsModelTemplateFilterProvider $filterProvider
        * @param PageRepositoryInterface $pageRepository
        * @param array $data
        */
        public function __construct(
        MagentoFrameworkViewElementContext $context,
        MagentoCmsModelTemplateFilterProvider $filterProvider,
        PageRepositoryInterface $pageRepository,
        array $data =
        ) {
        parent::__construct($context, $data);
        $this->filterProvider = $filterProvider;
        $this->pageRepository = $pageRepository;
        }

        /**
        * Prepare global layout
        *
        * @return $this
        */
        protected function _prepareLayout()
        {
        $pageId = $this->getPageId();
        $cmsPage = $this->pageRepository->getById($pageId);
        $this->setPage($cmsPage);
        return parent::_prepareLayout();
        }

        /**
        * Prepare HTML content
        *
        * @return string
        */
        protected function _toHtml()
        {
        $html = $this->filterProvider->getPageFilter()->filter($this->getPage()->getContent());
        return $html;
        }

        /**
        * Return identifiers for produced content
        *
        * @return array
        */
        public function getIdentities()
        {
        return [MagentoCmsModelPage::CACHE_TAG . '_' . $this->getPage()->getId()];
        }
        }





        share|improve this answer













        Add following xml in Design -> Layout Update XML



        <referenceContainer name="content">
        <block class="SRMagentoCommunityBlockPage" name="another_cms_page" after="cms_page">
        <arguments>
        <argument name="page_id" xsi:type="number">7</argument>
        </arguments>
        </block>
        </referenceContainer>


        enter image description here



        Now create app/code/SR/MagentoCommunity/Block/Page.php



        <?php
        namespace SRMagentoCommunityBlock;

        use MagentoCmsApiPageRepositoryInterface;

        class Page extends MagentoFrameworkViewElementAbstractBlock implements
        MagentoFrameworkDataObjectIdentityInterface
        {
        /**
        * @var MagentoCmsModelTemplateFilterProvider
        */
        private $filterProvider;

        /**
        * @var PageRepositoryInterface
        */
        private $pageRepository;

        /**
        * Page constructor.
        *
        * @param MagentoFrameworkViewElementContext $context
        * @param MagentoCmsModelTemplateFilterProvider $filterProvider
        * @param PageRepositoryInterface $pageRepository
        * @param array $data
        */
        public function __construct(
        MagentoFrameworkViewElementContext $context,
        MagentoCmsModelTemplateFilterProvider $filterProvider,
        PageRepositoryInterface $pageRepository,
        array $data =
        ) {
        parent::__construct($context, $data);
        $this->filterProvider = $filterProvider;
        $this->pageRepository = $pageRepository;
        }

        /**
        * Prepare global layout
        *
        * @return $this
        */
        protected function _prepareLayout()
        {
        $pageId = $this->getPageId();
        $cmsPage = $this->pageRepository->getById($pageId);
        $this->setPage($cmsPage);
        return parent::_prepareLayout();
        }

        /**
        * Prepare HTML content
        *
        * @return string
        */
        protected function _toHtml()
        {
        $html = $this->filterProvider->getPageFilter()->filter($this->getPage()->getContent());
        return $html;
        }

        /**
        * Return identifiers for produced content
        *
        * @return array
        */
        public function getIdentities()
        {
        return [MagentoCmsModelPage::CACHE_TAG . '_' . $this->getPage()->getId()];
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 10 hours ago









        Sohel RanaSohel Rana

        22.3k34460




        22.3k34460






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264670%2fhow-to-call-a-cms-page-in-another-cms-page-in-magento-2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            What other Star Trek series did the main TNG cast show up in?

            Berlina muro

            Berlina aerponto