How to call a CMS page in another CMS page in magento 2
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
add a comment |
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
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
add a comment |
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
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
magento2 cms
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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>
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()];
}
}
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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>
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()];
}
}
add a comment |
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>
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()];
}
}
add a comment |
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>
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()];
}
}
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>
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()];
}
}
answered 10 hours ago
Sohel RanaSohel Rana
22.3k34460
22.3k34460
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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