Mortillus Posted January 15, 2010 Share Posted January 15, 2010 Bonjour,Je suis en train de modifie le module de flux RSS pour avoir 2 flux configurable.Le premier s'affiche bien mais le deuxième reste videJe pense avoir fait une erreur de codageblockrss.php <?php include_once(_PS_CLASS_DIR_.'PEAR.php'); include_once(_PS_PEAR_XML_PARSER_PATH_.'Parser.php'); class Blockrss extends Module { function __construct() { $this->name = 'blockrss'; $this->tab = 'Blocks'; parent::__construct(); $this->displayName = $this->l('RSS feed block'); $this->description = $this->l('Adds a block displaying an RSS feed'); $this->version = '1.0'; $this->error = false; $this->valid = false; } function install() { Configuration::updateValue('RSS_FEED_TITLE', $this->l('RSS feed')); Configuration::updateValue('RSS_FEED_TITLE2', $this->l('RSS feed2')); Configuration::updateValue('RSS_FEED_NBR', 5); if (parent::install() == false OR $this->registerHook('leftColumn') == false) return false; } public function getContent() { $output = ''.$this->displayName.''; if (Tools::isSubmit('submitBlockRss')) { $urlfeed = strval(Tools::getValue('urlfeed')); $title = strval(Tools::getValue('title')); $urlfeed2 = strval(Tools::getValue('urlfeed2')); $title2 = strval(Tools::getValue('title2')); $nbr = intval(Tools::getValue('nbr')); if (($urlfeed AND !Validate::isUrl($urlfeed)) and ($urlfeed2 AND !Validate::isUrl($urlfeed2))) $errors[] = $this->l('Invalid feed URL'); elseif ((!$title OR empty($title) OR !Validate::isGenericName($title)) and (!$title2 OR empty($title2) OR !Validate::isGenericName($title2))) $errors[] = $this->l('Invalid title'); elseif (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr)) $errors[] = $this->l('Invalid number of feeds'); else { Configuration::updateValue('RSS_FEED_URL', $urlfeed); Configuration::updateValue('RSS_FEED_TITLE', $title); Configuration::updateValue('RSS_FEED_URL2', $urlfeed2); Configuration::updateValue('RSS_FEED_TITLE2', $title2); Configuration::updateValue('RSS_FEED_NBR', $nbr); } if (isset($errors) AND sizeof($errors)) $output .= $this->displayError(implode(' ', $errors)); else $output .= $this->displayConfirmation($this->l('Settings updated')); } return $output.$this->displayForm(); } public function displayForm() { $output = ' <form action="'.$_SERVER['REQUEST_URI'].'" method="post"> _path.'logo.gif" alt="" title="" />'.$this->l('Settings').' '.$this->l('Block title').' <input type="text" name="title" value="'.Tools::getValue('title', Configuration::get('RSS_FEED_TITLE')).'" /> '.$this->l('Create a title for the block (default: \'RSS feed\')').' '.$this->l('Block title').' <input type="text" name="title2" value="'.Tools::getValue('title2', Configuration::get('RSS_FEED_TITLE2')).'" /> '.$this->l('Create a title for the block (default: \'RSS feed2\')').' '.$this->l('Add a feed URL').' <input type="text" size="85" name="urlfeed" value="'.Tools::getValue('urlfeed', Configuration::get('RSS_FEED_URL')).'" /> '.$this->l('Add the url of the feed you wan\'t to use').' '.$this->l('Add a feed URL').' <input type="text" size="85" name="urlfeed2" value="'.Tools::getValue('urlfeed2', Configuration::get('RSS_FEED_URL2')).'" /> '.$this->l('Add the url of the feed you wan\'t to use').' '.$this->l('Number of threads displayed').' <input type="text" size="5" name="nbr" value="'.Tools::getValue('nbr', Configuration::get('RSS_FEED_NBR')).'" /> '.$this->l('The number of threads displayed by the block (default value: 5)').' <input type="submit" name="submitBlockRss" value="'.$this->l('Save').'" class="button" /> </form>'; return $output; } function hookRightColumn($params) { return $this->hookLeftColumn($params); } function hookLeftColumn($params) { global $smarty; // Conf $title = strval(Configuration::get('RSS_FEED_TITLE')); $url = strval(Configuration::get('RSS_FEED_URL')); $nb = intval(Configuration::get('RSS_FEED_NBR')); $title2 = strval(Configuration::get('RSS_FEED_TITLE2')); $url2 = strval(Configuration::get('RSS_FEED_URL2')); // Getting data La suite dans le dans le prochain message Link to comment Share on other sites More sharing options...
Mortillus Posted January 15, 2010 Author Share Posted January 15, 2010 La suite if ($contents = @file_get_contents($url)) { if ($url) @$src = new XML_Feed_Parser($contents); $content = ''; for ($i = 0; isset($src) AND $i < ($nb ? $nb : 5); ++$i) { @$item = $src->getEntryByOffset($i); $content .= 'link).'">'.Tools::htmlentitiesUTF8(@$item->title).''; } } if ($contents2 = @file_get_contents($url2)) { if ($url2) @$src = new XML_Feed_Parser($contents2); $content2 = ''; for ($i = 0; isset($src) AND $i < ($nb ? $nb : 5); ++$i) { @$item2 = $src->getEntryByOffset($i); $content2 .= 'link2).'">'.Tools::htmlentitiesUTF8(@$item2->title2).''; } } // Display smarty $smarty->assign('title', ($title ? $title : $this->l('RSS feed'))); $smarty->assign('content', (isset($content) ? $content : '')); $smarty->assign('title2', ($title2 ? $title2 : $this->l('RSS feed'))); $smarty->assign('content2', (isset($content2) ? $content2 : '')); return $this->display(__FILE__, 'blockrss.tpl'); } } ?> Dans le fichier blockrss.tpl <!-- Block RSS module--> Blog {if $content} {$content} {else} {l s='No RSS feed added' mod='blockrss'} {/if} <!-- /Block RSS module--> <!-- Block RSS module--> Forum {if $content2} {$content2} {else} {l s='No RSS feed added' mod='blockrss'} {/if} <!-- /Block RSS module--> Merci de votre aide d'avance Link to comment Share on other sites More sharing options...
BVince Posted January 15, 2010 Share Posted January 15, 2010 Bonjour,Le mieux serait que tu mettes ton début de développement sous forme de fichier téléchargeable, tu ne crois pas ?Mis à part tes problèmes d'affichage, est ce que ton module tel qu'il est aujourd'hui réalise bien les enregistrements dans la base de données ? Link to comment Share on other sites More sharing options...
Mortillus Posted January 15, 2010 Author Share Posted January 15, 2010 Désolé pour l'affichage Merci du coup de main.Je suis chez ovh et je mais pas mis de phpmyadmin sur le serv pour l'instant.Donc je ne sais pas Link to comment Share on other sites More sharing options...
BVince Posted January 16, 2010 Share Posted January 16, 2010 Je pense qu'il faut t'assurer que la base de donnée contient les informations que tu veux afficher, il y a un test dans le code qui vérifie la présence d'informations pour l'affichage, donc si ta base est vide, tu n'affiches rien. Pour besoin de phpMyAdmin pour accéder aux bases, essaie avec SqlYog téléchargeable ici http://code.google.com/p/sqlyog/downloads/list. Link to comment Share on other sites More sharing options...
Mortillus Posted January 16, 2010 Author Share Posted January 16, 2010 Oui il apparait bien dans la base de donnée Link to comment Share on other sites More sharing options...
Mortillus Posted January 16, 2010 Author Share Posted January 16, 2010 Désolé du dérengement j'ai trouvéC'était dan sle fichier PhpMerci Le topic peut etre fini 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