Back to Top

Hide Header and Footer HTML in AJAX response using Front Controller

Updated 22 February 2016

When we have to use Ajax in Prestashop front development, we have to create a file where we can perform the process. Generally, we have created an ajax folder and in that folder, we create and file ajax.php for our ajax processing, in this file we have to load Prestashop Classes by including config.inc file.

But instead of this, we can create a PrestaShop front controller and use this front controller for ajax processing.

Simply create a Front controller if not exist OR use the existing controller and process your Ajax on the same.

Prestashop front controller always has the HTML of Header and Footer, So while ajax response, we have to hide them.

If we are using the existing Front Controller where the other operation also performs, We have to create a condition in which we can hide the header and footer

Searching for an experienced
Prestashop Company ?
Find out More

Define display_header and display_footer variable false in Front Controller file init function

public function init()
{
    if (Tools::getValue('ajax')) {
        $this->display_header = false;
        $this->display_footer = false;
    }
}

Otherwise, simply define init function like this,

public function init()
{
    $this->display_header = false;
    $this->display_footer = false;
}

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home