[英]Prestashop Custom php page has 404 error in the title
我有3个网站。 我用网站的页眉和页脚创建了自定义php页面。 所有3个站点都使用相同的php文件。 在两个站点中,它工作正常,但在第三个站点中,页面标题显示404错误。
我不知道为什么会这样。 我检查了.htacccess文件并尝试匹配它们,但似乎也没问题。 我一直在Prestashop论坛上寻找答案,但找不到任何东西。
在以下两个站点中,如果您查看浏览器选项卡,则标题很好。
http://malverncomputerservices.com.au/payment.php
但是,在此第3个站点中,标题显示404错误。 页面运行正常,但页面顶部始终有错误。 我不知道这是怎么发生的,因为php文件只是原始文件的副本。
我找到了解决方案,它对我有用。 在根文件夹或内部文件夹中的任何位置创建php文件,然后粘贴以下代码。 经过1.6版测试。
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/config/config.inc.php';
$current = getcwd();
class ContentPageCutomized extends FrontController
{
public function initContent()
{
parent::initContent();
}
public function displayHeader()
{
$hook_header = Hook::exec('displayHeader');
if ((Configuration::get('PS_CSS_THEME_CACHE') || Configuration::get('PS_JS_THEME_CACHE')) && is_writable(_PS_THEME_DIR_.'cache'))
{
// CSS compressor management
if (Configuration::get('PS_CSS_THEME_CACHE'))
$this->css_files = Media::cccCSS($this->css_files);
//JS compressor management
if (Configuration::get('PS_JS_THEME_CACHE'))
$this->js_files = Media::cccJs($this->js_files);
}
$this->context->smarty->assign(array(
'meta_title' => 'My title'
));
// Call hook before assign of css_files and js_files in order to include correctly all css and javascript files
$this->context->smarty->assign(array(
'HOOK_HEADER' => $hook_header,
'HOOK_TOP' => Hook::exec('displayTop'),
'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),
'HOOK_RIGHT_COLUMN' => ($this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : ''),
'HOOK_FOOTER' => Hook::exec('displayFooter')
));
$this->context->smarty->assign(array(
'css_files' => $this->css_files,
'js_files' => ($this->getLayout() && (bool)Configuration::get('PS_JS_DEFER')) ? array() : $this->js_files,
'js_defer' => (bool)Configuration::get('PS_JS_DEFER'),
'errors' => $this->errors,
'display_header' => $this->display_header,
'display_footer' => $this->display_footer,
));
$layout = $this->getLayout();
if ($layout) {
if ($this->template) {
$template = $this->context->smarty->fetch($this->template);
echo 'might be';
} else {
// For retrocompatibility with 1.4 controller
ob_start();
$this->displayContent();
$template = ob_get_contents();
ob_clean();
}
$this->context->smarty->assign('template', $template);
$this->smartyOutputContent($layout);
} else {
Tools::displayAsDeprecated('layout.tpl is missing in your theme directory');
if ($this->display_header) {
$this->smartyOutputContent(_PS_THEME_DIR_.'header.tpl');
}
if ($this->template) {
$this->smartyOutputContent($this->template);
} else { // For retrocompatibility with 1.4 controller
$this->displayContent();
}
}
}
public function init()
{
parent::init();
}
public function displayContent()
{
?>
//Start your html content here
Your content here
//End your htmlcontent here
<?php
}
}
$controller=new ContentPageCutomized();
$controller->init();
$controller->setMedia();
$controller->initHeader();
$controller->displayHeader();
$controller->initContent();
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.