From d4c6e5b69c5ee1f16723cab5c2bd900c28681f9d Mon Sep 17 00:00:00 2001 From: Fabian Hurnaus Date: Fri, 12 Aug 2016 14:51:18 +0200 Subject: [PATCH 1/2] Add website field --- blockcontactinfos.php | 22 +++++++++++++++------- blockcontactinfos.tpl | 7 +++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/blockcontactinfos.php b/blockcontactinfos.php index d0c0847..a28e3de 100644 --- a/blockcontactinfos.php +++ b/blockcontactinfos.php @@ -23,11 +23,12 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA +* */ if (!defined('_CAN_LOAD_FILES_')) exit; - + class Blockcontactinfos extends Module { protected static $contact_fields = array( @@ -35,6 +36,7 @@ class Blockcontactinfos extends Module 'BLOCKCONTACTINFOS_ADDRESS', 'BLOCKCONTACTINFOS_PHONE', 'BLOCKCONTACTINFOS_EMAIL', + 'BLOCKCONTACTINFOS_WEBSITE', ); public function __construct() @@ -45,7 +47,7 @@ public function __construct() $this->version = '1.2.1'; $this->bootstrap = true; - parent::__construct(); + 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.'); @@ -58,6 +60,7 @@ public function install() 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_PHONE', Configuration::get('PS_SHOP_PHONE')); Configuration::updateValue('BLOCKCONTACTINFOS_EMAIL', Configuration::get('PS_SHOP_EMAIL')); + Configuration::updateValue('BLOCKCONTACTINFOS_WEBSITE', Configuration::get('PS_SHOP_WEBSITE')); $this->_clearCache('blockcontactinfos.tpl'); return (parent::install() && $this->registerHook('header') && $this->registerHook('footer')); } @@ -73,7 +76,7 @@ public function getContent() { $html = ''; if (Tools::isSubmit('submitModule')) - { + { foreach (Blockcontactinfos::$contact_fields as $field) Configuration::updateValue($field, Tools::getValue($field)); $this->_clearCache('blockcontactinfos.tpl'); @@ -87,15 +90,15 @@ 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( @@ -125,13 +128,18 @@ public function renderForm() 'label' => $this->l('Email'), 'name' => 'BLOCKCONTACTINFOS_EMAIL', ), + array( + 'type' => 'text', + 'label' => $this->l('Website'), + 'name' => 'BLOCKCONTACTINFOS_WEBSITE', + ), ), 'submit' => array( 'title' => $this->l('Save') ) ), ); - + $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; diff --git a/blockcontactinfos.tpl b/blockcontactinfos.tpl index 6e585fb..cc8a6ef 100644 --- a/blockcontactinfos.tpl +++ b/blockcontactinfos.tpl @@ -32,6 +32,13 @@ {if $blockcontactinfos_address != ''}
  • {$blockcontactinfos_address|escape:'html':'UTF-8'|nl2br}
  • {/if} {if $blockcontactinfos_phone != ''}
  • {l s='Tel' mod='blockcontactinfos'} {$blockcontactinfos_phone|escape:'html':'UTF-8'}
  • {/if} {if $blockcontactinfos_email != ''}
  • {l s='Email:' mod='blockcontactinfos'} {mailto address=$blockcontactinfos_email|escape:'html':'UTF-8' encode="hex"}
  • {/if} + {if $blockcontactinfos_website != ''} +
  • {l s='Contact:' mod='blockcontactinfos'} + + {$blockcontactinfos_website|escape:'html':'UTF-8'} + +
  • + {/if} From 21409827639d2dba9e13ae8a6720ea5a19937c91 Mon Sep 17 00:00:00 2001 From: Fabian Hurnaus Date: Fri, 12 Aug 2016 14:56:18 +0200 Subject: [PATCH 2/2] Update Changelog --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a5b15f4..5d9ff2c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,4 @@ +2016-08-12 14:55:00 +0200 // Add website field 2014-04-22 18:57:06 +0200 // Changelog updated 2014-03-24 11:43:28 +0100 / MO blockcontactinfos : ps_versions_compliancy modified (1.5.6.1 => 1.6) 2014-03-24 11:01:54 +0100 // MO blockcontactinfos/ : ps_versions_compliancy added