vyskoczilova Posted April 19, 2016 Share Posted April 19, 2016 I'm usually working with WP, but I need to manipulate a module blockcontactinfos on Prestashop - just simply add two more fields which will be shown on the front end, but somehow it's not working. I have carefully copied one of the fields, changed it everywhere but I when trying to clear the cache (in the Performance menu): 2 errors blockcontactinfos (parse error in /modules/blockcontactinfos/blockcontactinfos.php) blockcontactinfos (class missing in /modules/blockcontactinfos/blockcontactinfos.php) Could anybody help me out of this? Thanks a lot in advance. Prestashop is 1.6. Fields are displayed correctly in settings, values saved, but there is the error above and I just can't force the web page to load changed template file. blockcontactinfod.php (added the ones with `_url`), lines 31-141, changes marked with `// KV`: class Blockcontactinfos extends Module { protected static $contact_fields = array( 'BLOCKCONTACTINFOS_COMPANY', 'BLOCKCONTACTINFOS_ADDRESS', 'BLOCKCONTACTINFOS_ADDRESS_URL', // KV 'BLOCKCONTACTINFOS_PHONE', 'BLOCKCONTACTINFOS_PHONE_URL',// KV 'BLOCKCONTACTINFOS_EMAIL', ); public function __construct() { $this->name = 'blockcontactinfos'; $this->author = 'PrestaShop'; $this->tab = 'front_office_features'; $this->version = '1.2.0'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Contact information block'); $this->description = $this->l('This module will allow you to display your e-store\'s contact information in a customizable block.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } public function install() { Configuration::updateValue('BLOCKCONTACTINFOS_COMPANY', Configuration::get('PS_SHOP_NAME')); Configuration::updateValue('BLOCKCONTACTINFOS_ADDRESS', trim(preg_replace('/ +/', ' ', Configuration::get('PS_SHOP_ADDR1').' '.Configuration::get('PS_SHOP_ADDR2')."\n".Configuration::get('PS_SHOP_CODE').' '.Configuration::get('PS_SHOP_CITY')."\n".Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), Configuration::get('PS_SHOP_COUNTRY_ID'))))); Configuration::updateValue('BLOCKCONTACTINFOS_ADDRESS_URL', Configuration::get('PS_SHOP_ADDRESS_URL')); // KV Configuration::updateValue('BLOCKCONTACTINFOS_PHONE', Configuration::get('PS_SHOP_PHONE')); Configuration::updateValue('BLOCKCONTACTINFOS_PHONE_URL', Configuration::get('PS_SHOP_PHONE_URL')); // KV Configuration::updateValue('BLOCKCONTACTINFOS_EMAIL', Configuration::get('PS_SHOP_EMAIL')); $this->_clearCache('blockcontactinfos.tpl'); return (parent::install() && $this->registerHook('header') && $this->registerHook('footer')); } public function uninstall() { foreach (Blockcontactinfos::$contact_fields as $field) Configuration::deleteByName($field); return (parent::uninstall()); } public function getContent() { $html = ''; if (Tools::isSubmit('submitModule')) { foreach (Blockcontactinfos::$contact_fields as $field) Configuration::updateValue($field, Tools::getValue($field)); $this->_clearCache('blockcontactinfos.tpl'); $html = $this->displayConfirmation($this->l('Configuration updated')); } return $html.$this->renderForm(); } public function hookHeader() { $this->context->controller->addCSS(($this->_path).'blockcontactinfos.css', 'all'); } public function hookFooter($params) { if (!$this->isCached('blockcontactinfos.tpl', $this->getCacheId())) foreach (Blockcontactinfos::$contact_fields as $field) $this->smarty->assign(strtolower($field), Configuration::get($field)); return $this->display(__FILE__, 'blockcontactinfos.tpl', $this->getCacheId()); } public function renderForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Company name'), 'name' => 'BLOCKCONTACTINFOS_COMPANY', ), array( 'type' => 'textarea', 'label' => $this->l('Address'), 'name' => 'BLOCKCONTACTINFOS_ADDRESS', ), array( 'type' => 'text', 'label' => $this->l('URL na Google mapy'), 'name' => 'BLOCKCONTACTINFOS_ADDRESS_URL', ), // KV array( 'type' => 'text', 'label' => $this->l('Phone number'), 'name' => 'BLOCKCONTACTINFOS_PHONE', ), array( 'type' => 'text', 'label' => $this->l('Telefonní číslo bez mezer'), 'name' => 'BLOCKCONTACTINFOS_PHONE_URL', ), // KV array( 'type' => 'text', 'label' => $this->l('Email'), 'name' => 'BLOCKCONTACTINFOS_EMAIL', ), ), 'submit' => array( 'title' => $this->l('Save') ) ), ); blockcontactinfos.tpl (added the ones with `_url`), lines 32-33: {if $blockcontactinfos_address != ''}<li><pre> <a href="{$blockcontactinfos_phone_url|escape:'html':'UTF-8'}">{$blockcontactinfos_address|escape:'html':'UTF-8'|nl2br}</a></pre></li>{/if} {if $blockcontactinfos_phone != ''}<li>{l s='Tel' mod='blockcontactinfos'} <a href="tel:{$blockcontactinfos_phone_url|escape:'html':'UTF-8'}">{$blockcontactinfos_phone|escape:'html':'UTF-8'}</a></li>{/if} [1]: https://github.com/PrestaShop/blockcontactinfos 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