本文整理汇总了PHP中Mage_Core_Controller_Varien_Action::generateLayoutXml方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Controller_Varien_Action::generateLayoutXml方法的具体用法?PHP Mage_Core_Controller_Varien_Action::generateLayoutXml怎么用?PHP Mage_Core_Controller_Varien_Action::generateLayoutXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Controller_Varien_Action
的用法示例。
在下文中一共展示了Mage_Core_Controller_Varien_Action::generateLayoutXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _renderPage
/**
* Renders CMS page
*
* @param Mage_Core_Controller_Front_Action $action
* @param integer $pageId
* @param bool $renderLayout
* @return boolean
*/
protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true)
{
$page = Mage::getSingleton('cms/page');
if (!is_null($pageId) && $pageId !== $page->getId()) {
$delimeterPosition = strrpos($pageId, '|');
if ($delimeterPosition) {
$pageId = substr($pageId, 0, $delimeterPosition);
}
$page->setStoreId(Mage::app()->getStore()->getId());
if (!$page->load($pageId)) {
return false;
}
}
if (!$page->getId()) {
return false;
}
$inRange = Mage::app()->getLocale()->isStoreDateInInterval(null, $page->getCustomThemeFrom(), $page->getCustomThemeTo());
if ($page->getCustomTheme()) {
if ($inRange) {
list($package, $theme) = explode('/', $page->getCustomTheme());
Mage::getSingleton('core/design_package')->setPackageName($package)->setTheme($theme);
}
}
$action->getLayout()->getUpdate()->addHandle('default')->addHandle('cms_page');
$action->addActionLayoutHandles();
if ($page->getRootTemplate()) {
$handle = $page->getCustomRootTemplate() && $page->getCustomRootTemplate() != 'empty' && $inRange ? $page->getCustomRootTemplate() : $page->getRootTemplate();
$action->getLayout()->helper('page/layout')->applyHandle($handle);
}
Mage::dispatchEvent('cms_page_render', array('page' => $page, 'controller_action' => $action));
$action->loadLayoutUpdates();
$layoutUpdate = $page->getCustomLayoutUpdateXml() && $inRange ? $page->getCustomLayoutUpdateXml() : $page->getLayoutUpdateXml();
$action->getLayout()->getUpdate()->addUpdate($layoutUpdate);
$action->generateLayoutXml()->generateLayoutBlocks();
$contentHeadingBlock = $action->getLayout()->getBlock('page_content_heading');
if ($contentHeadingBlock) {
$contentHeading = $this->escapeHtml($page->getContentHeading());
$contentHeadingBlock->setContentHeading($contentHeading);
}
if ($page->getRootTemplate()) {
$action->getLayout()->helper('page/layout')->applyTemplate($page->getRootTemplate());
}
/* @TODO: Move catalog and checkout storage types to appropriate modules */
$messageBlock = $action->getLayout()->getMessagesBlock();
foreach (array('catalog/session', 'checkout/session', 'customer/session') as $storageType) {
$storage = Mage::getSingleton($storageType);
if ($storage) {
$messageBlock->addStorageType($storageType);
$messageBlock->addMessages($storage->getMessages(true));
}
}
if ($renderLayout) {
$action->renderLayout();
}
return true;
}
示例2: _renderPage
/**
* Renders CMS page
*
* @param Mage_Core_Controller_Front_Action $action
* @param integer $pageId
* @param bool $renderLayout
* @return boolean
*/
protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true)
{
$page = Mage::getSingleton('Mage_Cms_Model_Page');
if (!is_null($pageId) && $pageId !== $page->getId()) {
$delimeterPosition = strrpos($pageId, '|');
if ($delimeterPosition) {
$pageId = substr($pageId, 0, $delimeterPosition);
}
$page->setStoreId(Mage::app()->getStore()->getId());
if (!$page->load($pageId)) {
return false;
}
}
if (!$page->getId()) {
return false;
}
$inRange = Mage::app()->getLocale()->isStoreDateInInterval(null, $page->getCustomThemeFrom(), $page->getCustomThemeTo());
if ($page->getCustomTheme()) {
if ($inRange) {
Mage::getDesign()->setDesignTheme($page->getCustomTheme());
}
}
$action->getLayout()->getUpdate()->addHandle('default')->addHandle('cms_page');
$action->addActionLayoutHandles();
if ($page->getRootTemplate()) {
$handle = $page->getCustomRootTemplate() && $page->getCustomRootTemplate() != 'empty' && $inRange ? $page->getCustomRootTemplate() : $page->getRootTemplate();
$action->getLayout()->helper('Mage_Page_Helper_Layout')->applyHandle($handle);
}
Mage::dispatchEvent('cms_page_render', array('page' => $page, 'controller_action' => $action));
$action->loadLayoutUpdates();
$layoutUpdate = $page->getCustomLayoutUpdateXml() && $inRange ? $page->getCustomLayoutUpdateXml() : $page->getLayoutUpdateXml();
$action->getLayout()->getUpdate()->addUpdate($layoutUpdate);
$action->generateLayoutXml()->generateLayoutBlocks();
$contentHeadingBlock = $action->getLayout()->getBlock('page_content_heading');
if ($contentHeadingBlock) {
$contentHeading = $this->escapeHtml($page->getContentHeading());
$contentHeadingBlock->setContentHeading($contentHeading);
}
if ($page->getRootTemplate()) {
$action->getLayout()->helper('Mage_Page_Helper_Layout')->applyTemplate($page->getRootTemplate());
}
foreach (array('Mage_Catalog_Model_Session', 'Mage_Checkout_Model_Session') as $class_name) {
$storage = Mage::getSingleton($class_name);
if ($storage) {
$action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
}
}
if ($renderLayout) {
$action->renderLayout();
}
return true;
}