taniacr Posted January 12, 2016 Share Posted January 12, 2016 (edited) I want to create e new position (afterSlider) to hook the theme configurator module (based in the displayTopColumn position). Here's what I did: in the file /mytheme/modules/themeconfigurator/views/templates/themeconfigurator.php added, before the last closing bracket public function install() { if (!parent::install() || !$this->registerHook('displayTopColumn') || !$this->registerHook('afterSlider')) return false; return true; } public function hookafterSlider($params) { return $this->display(__FILE__, 'hook.tpl'); } Then in /mytheme/header.tpl i added <div class="after_slider">{hook h='afterSlider'}</div> But it's not working What am i doing wrong? Edited January 12, 2016 by taniacr (see edit history) Link to comment Share on other sites More sharing options...
aquahuang Posted January 13, 2016 Share Posted January 13, 2016 Do you create your own hook? INSERT INTO `ps_hook` (`name`, `title`, `description`) VALUES ('nameOfHook', 'The name of your hook', 'This is a custom hook!'); Link to comment Share on other sites More sharing options...
taniacr Posted January 14, 2016 Author Share Posted January 14, 2016 I read that since 1.5 that wasn't necessary.. So no.. Link to comment Share on other sites More sharing options...
taniacr Posted January 14, 2016 Author Share Posted January 14, 2016 Do you create your own hook? INSERT INTO `ps_hook` (`name`, `title`, `description`) VALUES ('nameOfHook', 'The name of your hook', 'This is a custom hook!'); Created the new position in my DB, cleared cache and reinitialized the module.. However it's still not working Link to comment Share on other sites More sharing options...
sooroos Posted January 29, 2016 Share Posted January 29, 2016 Hi, i have made it for prestashop 1.6.1.4 and it works perfectly.Steps to follow:1. Go to: www.yourwebseite.com/override/modules folder and there create a folder themeconfigurator, in it place a file with the name : themeconfigurator.php Edit this file and paste the code below: <?php if (!defined('_PS_VERSION_')) exit; class ThemeConfiguratorOverride extends ThemeConfigurator { public function install() { $themes_colors = array( 'theme1', 'theme2', 'theme3', 'theme4', 'theme5', 'theme6', 'theme7', 'theme8', 'theme9' ); $themes_fonts = array( 'font1' => 'Open Sans', 'font2' => 'Josefin Slab', 'font3' => 'Arvo', 'font4' => 'Lato', 'font5' => 'Volkorn', 'font6' => 'Abril Fatface', 'font7' => 'Ubuntu', 'font8' => 'PT Sans', 'font9' => 'Old Standard TT', 'font10' => 'Droid Sans' ); if (!parent::install() || !$this->installDB() || !$this->installFixtures(Language::getLanguages(true)) || !$this->registerHook('displayHeader') || !$this->registerHook('displayTopColumn') || !$this->registerHook('displayLeftColumn') || !$this->registerHook('displayRightColumn') || !$this->registerHook('displayHome') || !$this->registerHook('beforeFooter') || !$this->registerHook('displayFooter') || !$this->registerHook('displayBackOfficeHeader') || !$this->registerHook('actionObjectLanguageAddAfter') || !Configuration::updateValue('PS_TC_THEMES', serialize($themes_colors)) || !Configuration::updateValue('PS_TC_FONTS', serialize($themes_fonts)) || !Configuration::updateValue('PS_TC_THEME', '') || !Configuration::updateValue('PS_TC_FONT', '') || !Configuration::updateValue('PS_TC_ACTIVE', 1) || !Configuration::updateValue('PS_SET_DISPLAY_SUBCATEGORIES', 1) || !$this->createAjaxController() ) return false; return true; } public function hookBeforeFooter() { $this->context->smarty->assign(array( 'htmlitems' => $this->getItemsFromHook('beforeFooter'), 'hook' => 'beforeFooter' )); return $this->display(__FILE__, 'hook.tpl'); } protected function renderThemeConfiguratorForm() { $id_shop = (int)$this->context->shop->id; $items = array(); $hooks = array(); $this->context->smarty->assign('htmlcontent', array( 'admin_tpl_path' => $this->admin_tpl_path, 'hooks_tpl_path' => $this->hooks_tpl_path, 'info' => array( 'module' => $this->name, 'name' => $this->displayName, 'version' => $this->version, 'psVersion' => _PS_VERSION_, 'context' => (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 0) ? 1 : ($this->context->shop->getTotalShops() != 1) ? $this->context->shop->getContext() : 1 ) )); foreach ($this->languages as $language) { $hooks[$language['id_lang']] = array( 'home', 'top', 'left', 'right', 'beforeFooter', 'footer' ); foreach ($hooks[$language['id_lang']] as $hook) $items[$language['id_lang']][$hook] = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'themeconfigurator` WHERE id_shop = '.(int)$id_shop.' AND id_lang = '.(int)$language['id_lang'].' AND hook = \''.pSQL($hook).'\' ORDER BY item_order ASC' ); } $this->context->smarty->assign('htmlitems', array( 'items' => $items, 'theme_url' => $this->context->link->getAdminLink('AdminThemeConfigurator'), 'lang' => array( 'default' => $this->default_language, 'all' => $this->languages, 'lang_dir' => _THEME_LANG_DIR_, 'user' => $this->context->language->id ), 'postAction' => 'index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module=other&module_name='.$this->name.'', 'id_shop' => $id_shop )); $this->context->controller->addJqueryUI('ui.sortable'); return $this->display(__FILE__, 'views/templates/admin/admin.tpl'); } } 2. You have to edit 2 views for backend (PS, i dont knowhow to override these, maybe some1 give me a hint) You find the files in www.yourwebseite.com/modules/themeconfigurator/views/templates/admin first file is item.tpl, after line <option value="right"{if $hItem.hook == 'right'} selected="selected"{/if}>right</option> add the following <option value="beforeFooter"{if $hItem.hook == 'beforeFooter'} selected="selected"{/if}>beforeFooter</option> The second file is new.tpl, after line <option value="right">right</option> add the following <option value="beforeFooter">beforeFooter</option> 3. Open the file www.yourwebseite.com/themes/yourtheme/footer.tpl or wherever you want your new hook and add the following code wherever you want your hook to be displayed {hook h='beforeFooter'} 4. in my case icouldnt see the changes imediatelly so i had to uninstall and install the module themeconfigurator and everything was just fine Link to comment Share on other sites More sharing options...
tiendify Posted July 11, 2016 Share Posted July 11, 2016 Hi I´m having a probnlem with my theme configurator, when I try to expand the panel so ican change the images from the homepage, it contracts so i can´t change the images or put a new url because it closes before i can click on anyhting, can anybody help me, I´m using THEME CONFIGURATOR (V.2.1.1) and prestashop v1.6, thank you very much!!! Hi I´m having a problem with my theme configurator, when I try to expand the panel so ican change the images from the homepage, it contracts so i can´t change the images or put a new url because it closes before i can click on anyhting, can anybody help me, I´m using THEME CONFIGURATOR (V.2.1.1) and prestashop v1.6, thank you very much!!! Link to comment Share on other sites More sharing options...
vekia Posted July 11, 2016 Share Posted July 11, 2016 Hi I´m having a probnlem with my theme configurator, when I try to expand the panel so ican change the images from the homepage, it contracts so i can´t change the images or put a new url because it closes before i can click on anyhting, can anybody help me, I´m using THEME CONFIGURATOR (V.2.1.1) and prestashop v1.6, thank you very much!!! Hi I´m having a problem with my theme configurator, when I try to expand the panel so ican change the images from the homepage, it contracts so i can´t change the images or put a new url because it closes before i can click on anyhting, can anybody help me, I´m using THEME CONFIGURATOR (V.2.1.1) and prestashop v1.6, thank you very much!!! it is a matter of totally different case, not related to new hook. create new topic with your problem. Link to comment Share on other sites More sharing options...
crashbdx Posted November 1, 2016 Share Posted November 1, 2016 Hi, i have made it for prestashop 1.6.1.4 and it works perfectly. Steps to follow: 1. Go to: www.yourwebseite.com/override/modules folder and there create a folder themeconfigurator, in it place a file with the name : themeconfigurator.php Edit this file and paste the code below: <?php if (!defined('_PS_VERSION_')) exit; class ThemeConfiguratorOverride extends ThemeConfigurator { public function install() { $themes_colors = array( 'theme1', 'theme2', 'theme3', 'theme4', 'theme5', 'theme6', 'theme7', 'theme8', 'theme9' ); $themes_fonts = array( 'font1' => 'Open Sans', 'font2' => 'Josefin Slab', 'font3' => 'Arvo', 'font4' => 'Lato', 'font5' => 'Volkorn', 'font6' => 'Abril Fatface', 'font7' => 'Ubuntu', 'font8' => 'PT Sans', 'font9' => 'Old Standard TT', 'font10' => 'Droid Sans' ); if (!parent::install() || !$this->installDB() || !$this->installFixtures(Language::getLanguages(true)) || !$this->registerHook('displayHeader') || !$this->registerHook('displayTopColumn') || !$this->registerHook('displayLeftColumn') || !$this->registerHook('displayRightColumn') || !$this->registerHook('displayHome') || !$this->registerHook('beforeFooter') || !$this->registerHook('displayFooter') || !$this->registerHook('displayBackOfficeHeader') || !$this->registerHook('actionObjectLanguageAddAfter') || !Configuration::updateValue('PS_TC_THEMES', serialize($themes_colors)) || !Configuration::updateValue('PS_TC_FONTS', serialize($themes_fonts)) || !Configuration::updateValue('PS_TC_THEME', '') || !Configuration::updateValue('PS_TC_FONT', '') || !Configuration::updateValue('PS_TC_ACTIVE', 1) || !Configuration::updateValue('PS_SET_DISPLAY_SUBCATEGORIES', 1) || !$this->createAjaxController() ) return false; return true; } public function hookBeforeFooter() { $this->context->smarty->assign(array( 'htmlitems' => $this->getItemsFromHook('beforeFooter'), 'hook' => 'beforeFooter' )); return $this->display(__FILE__, 'hook.tpl'); } protected function renderThemeConfiguratorForm() { $id_shop = (int)$this->context->shop->id; $items = array(); $hooks = array(); $this->context->smarty->assign('htmlcontent', array( 'admin_tpl_path' => $this->admin_tpl_path, 'hooks_tpl_path' => $this->hooks_tpl_path, 'info' => array( 'module' => $this->name, 'name' => $this->displayName, 'version' => $this->version, 'psVersion' => _PS_VERSION_, 'context' => (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 0) ? 1 : ($this->context->shop->getTotalShops() != 1) ? $this->context->shop->getContext() : 1 ) )); foreach ($this->languages as $language) { $hooks[$language['id_lang']] = array( 'home', 'top', 'left', 'right', 'beforeFooter', 'footer' ); foreach ($hooks[$language['id_lang']] as $hook) $items[$language['id_lang']][$hook] = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'themeconfigurator` WHERE id_shop = '.(int)$id_shop.' AND id_lang = '.(int)$language['id_lang'].' AND hook = \''.pSQL($hook).'\' ORDER BY item_order ASC' ); } $this->context->smarty->assign('htmlitems', array( 'items' => $items, 'theme_url' => $this->context->link->getAdminLink('AdminThemeConfigurator'), 'lang' => array( 'default' => $this->default_language, 'all' => $this->languages, 'lang_dir' => _THEME_LANG_DIR_, 'user' => $this->context->language->id ), 'postAction' => 'index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module=other&module_name='.$this->name.'', 'id_shop' => $id_shop )); $this->context->controller->addJqueryUI('ui.sortable'); return $this->display(__FILE__, 'views/templates/admin/admin.tpl'); } } 2. You have to edit 2 views for backend (PS, i dont knowhow to override these, maybe some1 give me a hint) You find the files in www.yourwebseite.com/modules/themeconfigurator/views/templates/admin first file is item.tpl, after line <option value="right"{if $hItem.hook == 'right'} selected="selected"{/if}>right</option> add the following <option value="beforeFooter"{if $hItem.hook == 'beforeFooter'} selected="selected"{/if}>beforeFooter</option> The second file is new.tpl, after line <option value="right">right</option> add the following <option value="beforeFooter">beforeFooter</option> 3. Open the file www.yourwebseite.com/themes/yourtheme/footer.tpl or wherever you want your new hook and add the following code wherever you want your hook to be displayed {hook h='beforeFooter'} 4. in my case icouldnt see the changes imediatelly so i had to uninstall and install the module themeconfigurator and everything was just fine Thank you very much but did you find a way to override the admin module tpl files ? i dont and i feel bad overriding the classe but modifying the module core tpl... taste wrong to me Link to comment Share on other sites More sharing options...
Coal_Sa Posted June 15, 2017 Share Posted June 15, 2017 Hello, i'm searching how to: put my five themeconfigurator images, in a (new hook?), below displayHome. I just want the images to display full width. Can someone point me in the right direction ? loosing my mind Link to comment Share on other sites More sharing options...
tmaes Posted July 1, 2017 Share Posted July 1, 2017 (edited) Hi, I'd like to add a hook too and the soroos solution seems to be really good, but when I desinstall/reinstall the module, I get an error page saying: [PrestaShop] Fatal error in module file :/htdocs/webshop/override/modules/themeconfigurator/themeconfigurator.php: Call to private method ThemeConfigurator::installDB() from context 'ThemeConfiguratorOverride' I'm on Prestashop 1.6.1.11, does someone have an idea on how to correct the problem? Thanks in advance, -- tmaes auto answer: I don't know if its a regular method but I added: private function installDB() { return ( Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'themeconfigurator`') && Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'themeconfigurator` ( `id_item` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_shop` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `item_order` int(10) unsigned NOT NULL, `title` VARCHAR(100), `title_use` tinyint(1) unsigned NOT NULL DEFAULT \'0\', `hook` VARCHAR(100), `url` TEXT, `target` tinyint(1) unsigned NOT NULL DEFAULT \'0\', `image` VARCHAR(100), `image_w` VARCHAR(10), `image_h` VARCHAR(10), `html` TEXT, `active` tinyint(1) unsigned NOT NULL DEFAULT \'1\', PRIMARY KEY (`id_item`) ) ENGINE = '._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;') ); } after the install() function (in fact as in the original themeconfigurator.php) in the override file and it seeems to work... Edited July 1, 2017 by tmaes (see edit history) Link to comment Share on other sites More sharing options...
stdeykun Posted October 24, 2018 Share Posted October 24, 2018 On 29.01.2016 at 10:23 AM, sooroos said: 4. in my case icouldnt see the changes imediatelly so i had to uninstall and install the module themeconfigurator and everything was just fine If you don't want reinstall this module to add themeconfigurator to new Hook, just add: $this->registerHook('beforeFooter'); to hookdisplayHeader(), refresh homepage of the shop, and remove this line. 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