不确定采用最佳方法解决此问题并正在寻找解决方案。我需要创建一个具有特定主题作为设计的空白页(稍后将向其添加代码)。我已经在/ app / design / frontend / indigo / mytheme /中创建了自定义主题,并且需要知道如何创建一个页面,让它称为/test.php并已应用了该主题。
到目前为止,代码是这样,但这仅显示默认主题:
<?php
define('MAGENTO_ROOT', $_SERVER['DOCUMENT_ROOT']);
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
if (!file_exists($mageFilename)) {
echo $mageFilename." was not found";
exit;
}
require_once $mageFilename;
Mage::app()->loadArea('frontend');
$layout = Mage::getSingleton('core/layout');
//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();
//get the loaded head and header blocks and output
$headBlock = $layout->getBlock('head');
$headerBlock = $layout->getBlock('header');
$footerBlock = $layout->getBlock('footer');
echo $headBlock->toHtml() . $headerBlock->toHtml();
?>
My content goes here
<?php
echo $footerBlock->toHtml();
?>
该解决方案非常基础,您只需要设置商店ID:
Mage::app()->setCurrentStore(STORE_ID);
因此,最终代码如下所示:
<?php
define('MAGENTO_ROOT', $_SERVER['DOCUMENT_ROOT']);
define('STORE_ID', 15);
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
if (!file_exists($mageFilename)) {
echo $mageFilename." was not found";
exit;
}
require_once $mageFilename;
Mage::app()->setCurrentStore(STORE_ID);
Mage::app()->loadArea('frontend');
$layout = Mage::getSingleton('core/layout');
//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php echo $layout->getBlock('head')->toHtml() ?>
</head>
<body>
<?php echo $layout->getBlock('after_body_start')->toHtml() ?>
<?php echo $layout->getBlock('global_notices')->toHtml() ?>
<?php echo $layout->getBlock('header')->toHtml() ?>
<div class="content-wrapper">
<div class="container_12">
<?php echo $layout->getBlock('breadcrumbs')->toHtml() ?>
<div class="main-container col1-layout">
<div class="grid_12 col-main">
<?php echo $layout->getBlock('global_messages')->toHtml() ?>
<?php echo $layout->getBlock('content')->toHtml() ?>
My content goes here
</div>
<div class="clear"></div>
</div>
</div>
</div>
<?php echo $layout->getBlock('footer')->toHtml() ?>
</body>
</html>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句