我有一个外部网页说" test.php"我已加载网站标题&来自Magento框架的页脚块用作标题&此外部页面中的页脚。除了网址链接,一切正常。这是我到目前为止所做的:
include 'app/Mage.php';
Mage::app();
umask(0);
Mage::app()->loadArea('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
$layout = Mage::getSingleton('core/layout');
//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();
//load header
$headBlock = $layout->getBlock('head');
$headerBlock = $layout->getBlock('header');
echo $headBlock->toHtml() . $headerBlock->toHtml();
// load footer
$footerBlock = $layout->getBlock('footer');
echo $footerBlock->toHtml();
问题是此页面生成的url链接在其基本URL中包含test.php。
说我有一个链接"关于我们"。在magento中为此链接生成的网址是" http://localhost/myapp/index.php/about.html"但是为test.php上的相同链接生成的网址是" http://localhost/myapp/test.php/about.html"。
如何解决这个问题?
OR
还有其他方法可以加载主题的页眉和页脚吗?
OR
有没有什么方法可以将test.php加载为magento中的iframe并传递url参数?
答案 0 :(得分:0)
将下面的行添加到第一个为我工作的脚本中。
$_SERVER['SCRIPT_NAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_NAME']);
$_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_FILENAME']);
所以,最终的脚本如下:
include 'app/Mage.php';
//Added
$_SERVER['SCRIPT_NAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_NAME']);
$_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_FILENAME']);
Mage::app();
umask(0);
Mage::app()->loadArea('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
$layout = Mage::getSingleton('core/layout');
//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();
//load header
$headBlock = $layout->getBlock('head');
$headerBlock = $layout->getBlock('header');
echo $headBlock->toHtml() . $headerBlock->toHtml();
// load footer
$footerBlock = $layout->getBlock('footer');
echo $footerBlock->toHtml();