en Jump to content
  • 0
telnett

Product tabs in 1.7

Question

So, with displayProductTab and displayProductTabContent removed, how do we go about squeezing in new tabs on the product vew page?

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

 

Use the new productExtraContent hook like this:
    public function hookDisplayProductExtraContent($params)
    {
        $productExtraContent = new ProductExtraContent();
        $productExtraContent->setTitle($this->l('Gallery'));
        $productExtraContent->setContent($this->context->smarty->fetch(
            'module:nc_gallery/views/templates/front/tab_content.tpl'
        ));
            
        return array($productExtraContent);
    }

This code is similar to what I have in my Image/Video Gallery module to create a "Gallery" tab and load the content from tab_content.tpl.

 

 

 

Thank you for your quick and accurate response!

 

With this, I ended up having "mod_fcgid: stderr: PHP Fatal error:  Class 'ProductExtraContent' not found ..." written to my error_log.

 

Obviously I was still missing something, but since you got me on the right track, here is what worked for me:

public function hookdisplayProductExtraContent($params)
{        
    $array = array();
    $array[] = (new PrestaShop\PrestaShop\Core\Product\ProductExtraContent())
            ->setTitle('tittle')
            ->setContent('content');
    return $array;
}

Hope this thread will be useful for future learners!

Share this post


Link to post
Share on other sites
  • 0
Use the new productExtraContent hook like this:
    public function hookDisplayProductExtraContent($params)
    {
        $productExtraContent = new ProductExtraContent();
        $productExtraContent->setTitle($this->l('Gallery'));
        $productExtraContent->setContent($this->context->smarty->fetch(
            'module:nc_gallery/views/templates/front/tab_content.tpl'
        ));
            
        return array($productExtraContent);
    }

This code is similar to what I have in my Image/Video Gallery module to create a "Gallery" tab and load the content from tab_content.tpl.

Share this post


Link to post
Share on other sites
  • 0

Sorry, I forgot to mention you should add the following to the top of the file so my code works above:

use PrestaShop\PrestaShop\Core\Product\ProductExtraContent;

Share this post


Link to post
Share on other sites
  • 0

Hi,

I come in this discussion because I need to know where you place your function, is it in one module or do you override Something.

Sorry my question is perhaps stupid but I am new in PS development.

Jean

 

Share this post


Link to post
Share on other sites
  • 0

It should be in the main module file. For example, modules/nc_gallery/nc_gallery.php in my module. Add the use line to the top of the file and the hookDisplayProductExtraContent function anywhere after the class line and before the last }.

Also, don't forget to register the hook in the install() function using the code $this->registerHook('displayProductExtraContent')

Edited by rocky

Share this post


Link to post
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

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More