name = 'canonicalurl'; $this->tab = 'Tools'; $this->version = 1.3; parent::__construct(); $this->displayName = $this->l('Canonical URL'); $this->description = $this->l('Improve SEO by avoiding the "duplicate content" status for your Website.'); if (strlen(Configuration::get('CANONICAL_URL')) == 0) $this->warning = $this->l('You must set the canonical URL to avoid "duplicate content" status for your Website.'); } function install() { if (!parent::install() OR !$this->registerHook('header') OR !Configuration::updateValue('CANONICAL_URL', '')) return false; return true; } public function getContent() { $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitCanonicalUrl')) { $canonicalUrl = pSQL(Tools::getValue('canonicalUrl')); if (strlen($canonicalUrl) == 0) $output .= '
'.$this->l('Canonical URL : invalid URL.').'
'; else { Configuration::updateValue('CANONICAL_URL', $canonicalUrl); $output .= '
'.$this->l('Confirmation').''.$this->l('Settings updated').'
'; } } return $output.$this->displayForm(); } public function displayForm() { return '
'.$this->l('Settings').'
http(s):///some/directories/a_prestashop_webpage.php

'.$this->l('Choose the primary domain name for your referencing (e.g., www.myshop.com or myshop.com or mywebsite.com). Note: Do not include the last slash ("/"), the "/index.php" suffix, or the "http(s)://" prefix.').'

'; } function hookHeader($params) { global $smarty, $protocol, $rewrited_url; $canonicalUrl = Configuration::get('CANONICAL_URL'); $ps_request = str_replace(__PS_BASE_URI__, '', $_SERVER['REQUEST_URI']); if (strlen(Configuration::get('CANONICAL_URL')) > 0) $smarty->assign('canonical_url', $protocol.$canonicalUrl.$_SERVER['REQUEST_URI']); return $this->display(__FILE__, 'canonicalurl.tpl'); } } ?>