简体   繁体   English

如何在magento的phtml文件中调用cms页面?

[英]How to call a cms page in a phtml file in magento?

I need to display a CMS page inside my custom module's phtml file. 我需要在自定义模块的phtml文件中显示CMS页面。 Is there any way I can include it either through xml layout or via coding directly in phtml file? 有什么办法可以通过xml布局或直接在phtml文件中进行编码来包含它? I know we can add a cms block but how can we add a cms page? 我知道我们可以添加cms块,但是如何添加cms页面?

Try the below code in your phtml file 在您的phtml文件中尝试以下代码

 $page = Mage::getModel('cms/page')->load('home_page','identifier');
 echo $page->getContent();

This code check if cms page is active then it will display page content 此代码检查cms页面是否处于活动状态,然后将显示页面内容

$page = Mage::getModel('cms/page')->load('top_offer','identifier');

echo $page->getIsActive()?$page->getContent():'';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 CMS 页面 Magento 中调用 PHTML 文件 - how to call a PHTML file within a CMS page Magento Magento如何在cms页面上将phtml文件作为块调用? - Magento how to call phtml file as a block on cms page? Magento 2 - 如何在另一个phtml文件,xml布局,静态块和cms页面中调用自定义phtml文件 - Magento 2 - How to call a custom phtml file in another phtml file, xml layout, static block and cms page Magento 2 - 如何在另一个 phtml 文件、xml 布局、静态块和 cms 页面中调用自定义 phtml 文件? - Magento 2 - How to call a custom phtml file in another phtml file, xml layout, static block and cms page? Magento通过phtml文件中的锚标记调用cms页面 - Magento call cms page through anchor tag from phtml file 在cms页面中调用phtml文件不起作用Magento2 - Call phtml file in cms page not working Magento2 如何在cms页面中调用phtml文件以设置页面标题 - How to call a phtml file in cms page to set page title magento:如何将phtml块从模板添加到CMS页 - magento: How to add a phtml block from the template to a CMS page 如何在Magento CMS页面上使用自定义“ Head.phtml”? - How to use custom “Head.phtml” for a Magento CMS page? magento view.phtml在具有特定产品ID的cms页面上调用,但getchildhtml方法未呈现 - magento view.phtml call on cms page with specific product id but getchildhtml method not render
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM