Jump to content

Override/change reviews tab in product from module


numediaweb

Recommended Posts

I read in the forums that it is impossible to change the theme templates from a custom module.

 

In my case, using prestashop 1.6, I want the reviews tab to have a different title like:

Reviews (15)

and the content of the tab, i want to feed it with reviews from a different source (not using the current shop reviews saved in the DB).

 

Now inside my module I made a hook in the install:

        if (!parent::install() ||
            !$this->registerHook('displayFooterProduct') || //
            !Configuration::updateValue('MYMODULE_NAME', 'My Reviews')
        )
            return false;

Which will trigger:

     /**
     * Returns tab title & content
     */
    public function hookProductFooter($params)
    {
        $tabTitleSuffix = ' (50)';
        $tabContent = '<p>here are some reviews for you</p>';
        $this->context->smarty->assign('tabTitleSuffix', $tabTitleSuffix);
        $this->context->smarty->assign('tabContent', $tabContent);

        // Call the template containing the HTML-code of our new tab content:
        return $this->display(__FILE__, 'producttabcontent.tpl');
    }

In the producttabcontent.tpl:
 

<section class="page-product-box">
    <h3 id="#idTabeKomiReviews" class="idTabHrefShort page-product-heading">{l s='Reviews'} {$tabTitleSuffix}</h3>
    <div id="idTabeKomiReviews">
        <div id="product_ekomi_reviews_block_tab">
            {*call script that sends producttab.php content to this template :*}
            {$tabContent}
        </div>
    </div>
</section>

What is the best practice do you think/advise guys in order to make my module alter the reviews tab in product page?

 

A second question, is it possible to make it work with whatever the theme is used in the shop?

Edited by numediaweb (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...