widepresta Posted December 12, 2016 Share Posted December 12, 2016 How to create a new tab Prestashop 1.7 ? Prestashop 1.6 public function hookDisplayAdminProductsExtra() { $this->context->smarty->assign(array( 'id_product' => Tools::getValue('id_product'), 'id_lang' => $this->context->language->id, 'languages' => Language::getLanguages(), 'default_language' => $this->default_language, )); return $this->display(__FILE__, 'views/templates/admin/tab.tpl'); } In the new version also creates a new tab... But how to connect file tab.html.twig ? Transfer variables with the value of ? Thanks. Link to comment Share on other sites More sharing options...
vekia Posted December 12, 2016 Share Posted December 12, 2016 example: public function hookDisplayAdminProductsExtra($params) { $this->context->smarty->assign(array('id_product' => $params['id_product'])); return $this->context->smarty->fetch('module:MODULE_NAME/views/tab.tpl'); } 1 Link to comment Share on other sites More sharing options...
widepresta Posted December 12, 2016 Author Share Posted December 12, 2016 (edited) example: public function hookDisplayAdminProductsExtra($params) { $this->context->smarty->assign(array('id_product' => $params['id_product'])); return $this->context->smarty->fetch('module:MODULE_NAME/views/tab.tpl'); } Thanks for your reply I would like to include file: tab.html.twig and use use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormError; Symfony how to connect to the module? Edited December 13, 2016 by widepresta (see edit history) Link to comment Share on other sites More sharing options...
widepresta Posted December 12, 2016 Author Share Posted December 12, 2016 (edited) How to create form_widget? For example the fields of product settings src\PrestaShopBundle\Resources\views\Admin\Product\form.html.twig example: name product form_widget(form.step1.name) I would like a new field in the new tab to create in this way or short description form_widget(form.step1.description_short) Edited December 12, 2016 by widepresta (see edit history) Link to comment Share on other sites More sharing options...
savvato Posted December 25, 2016 Share Posted December 25, 2016 I'm do so public function hookDisplayAdminProductsExtra($params){ $id_product = (int)Tools::getValue('id_product', $params['id_product']); $this->smarty->assign(array( 'id_product' => $id_product, 'xml' => $this->getCMLid($id_product), 'xml_c' => $this->getCMLidComb($id_product), 'varning' => $res )); return $this->smarty->fetch('module:ecm_cmlid/views/templates/admin/ecm_cmlid.tpl'); } don't work. What am I doing wrong? Link to comment Share on other sites More sharing options...
widepresta Posted December 26, 2016 Author Share Posted December 26, 2016 I'm do so public function hookDisplayAdminProductsExtra($params){ $id_product = (int)Tools::getValue('id_product', $params['id_product']); $this->smarty->assign(array( 'id_product' => $id_product, 'xml' => $this->getCMLid($id_product), 'xml_c' => $this->getCMLidComb($id_product), 'varning' => $res )); return $this->smarty->fetch('module:ecm_cmlid/views/templates/admin/ecm_cmlid.tpl'); } don't work. What am I doing wrong? Try this public function hookDisplayAdminProductsExtra($params) { $id_product = $params['id_product']; $res = false; $this->context->smarty->assign(array( 'id_product' => $id_product, 'xml' => $this->getCMLid($id_product), 'xml_c' => $this->getCMLidComb($id_product), 'varning' => $res )); return $this->display(__FILE__, 'views/templates/admin/ecm_cmlid.tpl'); } what is the $res ? Link to comment Share on other sites More sharing options...
widepresta Posted December 26, 2016 Author Share Posted December 26, 2016 This include smarty file... Who knows how to include to the module Symfony ? and include "tab.html.twig" for new tab in product details Thanks 1 Link to comment Share on other sites More sharing options...
savvato Posted December 26, 2016 Share Posted December 26, 2016 Try this public function hookDisplayAdminProductsExtra($params) { $id_product = $params['id_product']; $res = false; $this->context->smarty->assign(array( 'id_product' => $id_product, 'xml' => $this->getCMLid($id_product), 'xml_c' => $this->getCMLidComb($id_product), 'varning' => $res )); return $this->display(__FILE__, 'views/templates/admin/ecm_cmlid.tpl'); } what is the $res ? don't work... $res is boolean variable Link to comment Share on other sites More sharing options...
rocky Posted December 30, 2016 Share Posted December 30, 2016 I'm also struggling to get to this work in PrestaShop v1.7.0.3. I can't even get the "Module options" tab to show. It seems AdminProductsController::initFormModules is never called, so the displayAdminProductsExtra hook is never executed. I can't even find any modules that have it successfully working. Is it a bug in PrestaShop that needs to be fixed? Link to comment Share on other sites More sharing options...
savvato Posted January 5, 2017 Share Posted January 5, 2017 Is it a bug in PrestaShop that needs to be fixed? Maybe yes. Link to comment Share on other sites More sharing options...
savvato Posted January 10, 2017 Share Posted January 10, 2017 (edited) Answer from PS support I just tested and it's working. You just need to have at least one module hooked on displayAdminProductsExtra and the tab will appear. It's not in the controller anymore, it's called in the twig file (https://github.com/PrestaShop/PrestaShop/blob/develop/src/PrestaShopBundle/Resources/views/Admin/Product/form.html.twig#L933) What is your problem exactly? but from me didn't help... any modules compatable 1.7 with hook DisplayAdminProductsExtra Edited January 10, 2017 by savvato (see edit history) Link to comment Share on other sites More sharing options...
savvato Posted January 11, 2017 Share Posted January 11, 2017 on clear installed PS 1704 worked... but on PS upgraded from 1700->1701->1702->1703->1704 NOT!!! saint Madonna, what is the...(there are many abusive words) Link to comment Share on other sites More sharing options...
Promokit Posted April 3, 2017 Share Posted April 3, 2017 Does anybody have a solution regarding tabs? 1 Link to comment Share on other sites More sharing options...
kimwebfan Posted April 4, 2017 Share Posted April 4, 2017 Hello, did you find a way to create new tabs with Symfony/Twig? Link to comment Share on other sites More sharing options...
abriggs Posted April 15, 2017 Share Posted April 15, 2017 Deliberate cross post with thread #568375! There's a few threads on this topic, yet no answers. A little help please, prestashop? Link to comment Share on other sites More sharing options...
mickaelandrieu Posted June 11, 2018 Share Posted June 11, 2018 Hi, it works as expected in 1.7.3 and 1.7.4, keep your shop up to date to get the bug fixes. Regards, Link to comment Share on other sites More sharing options...
maofree Posted July 18, 2018 Share Posted July 18, 2018 Hi yes on the last version works but how to use the new UI-Kit helpers to use the same style? the smarty solution is good for the 1.6.x but not on the 1.7.x for that product page I think should be used the same solution like this https://devdocs.prestashop.com/1.7/modules/concepts/hooks/use-hooks-on-modern-pages/ but I do not know how to create a form with the various types of fields and use the new helpers Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted July 6, 2019 Share Posted July 6, 2019 @widepresta can you find the solution using Symfony ? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now