name = 'cyb_rss'; $this->tab = 'cyb_rss'; $this->version = '1'; $this->author = 'Cyberscope Gabriel'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; $this->display = 'view'; parent::__construct(); $this->displayName = $this->l('Cyberscope RSS'); $this->description = $this->l(''); $this->confirmUninstall = $this->l('Êtes-vous sûr de vouloir désinstaller ce module ?'); $this->templateFile = 'module:cyb_rss/cyb_rss.tpl'; } public function install(){ if(!parent::install() || !Configuration::updateValue('cyb_rss', '') || !$this->registerHook('displayRSS')){ return false; } else{ return true; } } public function uninstall(){ if(!parent::uninstall() || !Configuration::deleteByName('cyb_rss')){ return false; } else{ return true; } } public function hookHeader() { $this->context->controller->registerStylesheet('css-cyb-fluxrss', 'modules/' . $this->name. '/views/css/styles.css', [ 'media' => 'all', 'priority' => 0, ] ); } public function hookDisplayRSS(){ global $smarty; $content = file_get_contents("https://www.bio-concept-pharma.com/blog/?fluxrss=1"); $xml_element = new SimpleXMLElement($content); $xml_array = []; $nb_voulu = 0; foreach($xml_element->bio as $element) { $xml_array[] = array( 'titre'=> html_entity_decode((string)$element->titre), 'img'=> $element->image, 'url'=>$element->url ); $nb_voulu++; if($nb_voulu>=3){ break; } } $smarty->assign('xml_array', $xml_array); return $this->display(__FILE__,'/views/templates/hook/flux.tpl'); } }