简体   繁体   中英

Prestashop Custom php page has 404 error in the title

I have 3 websites. I created custom php page with site header and footer. The same php file is used in all 3 sites. In two sites it works perfectly but in the 3rd site the title of the page shows 404 error.

I cannot figure out why this is happening. I checked .htacccess file and tried to match them but it seems ok too. I have been looking for an answer on Prestashop forums but could not find anything.

In the following two sites, if you look at the browser tab the title is fine.

http://malverncomputerservices.com.au/payment.php

https://i.net.au/payment.php

In this 3rd site however, the title shows 404 error. The page functions properly but always has error on top of the page. I don't know how this happened as the php files are just copies of the original.

http://toorakcomputerservices.com.au/payment.php

I found the solution and it works for me. Create php file anywhere either in root folder or inner folder and paste the below code. Tested with 1.6 version.

<?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();
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM