tarek.fellah Posted September 10, 2012 Share Posted September 10, 2012 (edited) Bonjour, Je partage avec vous une astuce que j'ai adopté pour modifier le module blockcms à qu'il soit un menu vertical. Le menu marche bien que ce soit avec l'activiation d'url ou sans. J'ai fait ceci : Dans modules/blockcms/blockcms.php, j'ai ajouter ceci à la méthode hookLeftColumn $urlVars =explode("/",$_SERVER['REQUEST_URI']); if ((int)(Configuration::get('PS_REWRITING_SETTINGS') == 1)){ $urlVars =explode("/",$_SERVER['REQUEST_URI']); $link_url = $urlVars[sizeof($urlVars)-1]; $tab_id_cms = array(); $tab_id_cms = explode("-",$link_url); $id_cms = $tab_id_cms[0]; } else{ $id_cms= Tools::getValue('id_cms'); } $cms = new CMS((int)$id_cms); [size=1]$cat= $cms->id_cms_category; $smarty->assign('id_category', $cat); avant l'appel de return $this->display(__FILE__, 'blockcms.tpl'); il faut ne pas oublié de faire l'inclusion du classe CMS avec include_once(dirname(__FILE__) .'/../../classes/CMS.php'); avant la définition de la classe. Dans la méthode public static function getCMStitles($location) j'ai ajouté $content[$key]['id_cms_category'] =$cmsCategory['id_cms_category']; après $content[$key]['category_name'] =$cmsCategory['category_name']; à la fin de la méthode et au sein de la boucle foreach ($cmsCategories AS $cmsCategory) Ensuite dans le tpl: dans VOTRE_THEME/modules/blckcms/blockcms.tpl (s'il ya de l'override) ou bien dans modules/blockcms/blockcms.tpl Il faut ajouter une condition if pour afficher que le bloc cms relative à la page cms en cours après {foreach from=$cms_titles key=cms_key item=cms_title} il faut ajouter {if $id_category == $cms_title.id_cms_category} à la fin il faut fermer le if par {/if] avant le {/foreach} qui précéde le commentaire <!-- /Block CMS module --> Vous pouvez ensuite modifier le css du module à votre guise J'espère que ce post vous a aidé pour adapter le module blockcms pour qu'il soit semblable à un menu vertical. J'espère que cette solution vous as aidé et vous a permis de faire des économies de quelques € blockcms.zip Edited October 16, 2012 by tarek.fellah (see edit history) 1 Link to comment Share on other sites More sharing options...
Patric Posted September 10, 2012 Share Posted September 10, 2012 Bonjour tarek.fellah, Je t'invite à utiliser la balise "code" pour la mise en forme de ton post, parce que là c'est illisible. 1 Link to comment Share on other sites More sharing options...
tarek.fellah Posted September 10, 2012 Author Share Posted September 10, 2012 Bonjour, C'est fait maintenant Link to comment Share on other sites More sharing options...
Mellow Posted September 10, 2012 Share Posted September 10, 2012 (edited) Oups!!! J'ai mis trop de temps à écrire, entre temps ça a été réglé Edited September 10, 2012 by Mellow (see edit history) 1 Link to comment Share on other sites More sharing options...
tarek.fellah Posted September 10, 2012 Author Share Posted September 10, 2012 (edited) Pour le principe, je récupère l'id catégorie de la page cms en cours, depuis le php, et dans le tpl n'afficher que le bloc cms relative à cette catégorie. Si vous avez connaissance du module block cms ,il affiche un bloc (menu) pour chaque catégorie cms spécifié dans le backoffice Dans le tpl, la boucle {foreach from=$cms_titles key=cms_key item=cms_title} parcours l'ensemble des blocs cms (pour la langue courante) des différends catégorie (ajouté au BO du module blockcms) donc pour avoir le bloc cms de la catégorie de la page cms en cours je fais {if $id_category == $cms_title.id_cms_category} ces deux variables assignés dans le blockcms.php comme ceci $smarty->assign('id_category', $cat);$smarty->assign(array('block' => 1,'cms_titles' => $cms_titles,'theme_dir' => _PS_THEME_DIR_)); $cms_titles est un tableau de tableaux dans GetCmsTitles($location) $cms_titles = self::getCMStitles(self::LEFT_COLUMN); return un tableau qui contient l'ensemble des bloc cms créés dans le BO du module. Dans GetCmsTitles($location) j'ai ajouté $content[$key]['id_cms_category'] =(int)$cmsCategory['id_cms_category']; pour avoir l'id catégorie de chaque bloc J'espère être le plus clair possible. Edited September 10, 2012 by tarek.fellah (see edit history) Link to comment Share on other sites More sharing options...
rafamerida Posted October 15, 2012 Share Posted October 15, 2012 Hi Tarek, Could you attach the PHP and TPL files that you used? I followed every step, but mine doesn't work. I get all the blocks in every CMS page. Please... Link to comment Share on other sites More sharing options...
tarek.fellah Posted October 16, 2012 Author Share Posted October 16, 2012 I attached the module, in mycase, the tpl file is located in my them folder, under themFolder/modules/blockcms. to test it correctly you should link a menu item (horizontal fro exemple) to a category cms item or cms page. 1 Link to comment Share on other sites More sharing options...
rafamerida Posted October 16, 2012 Share Posted October 16, 2012 (edited) 1 million thanks Tarek, it worked perfect for me! Do you now how could I highlight the current page <li><a> in that block? I mean to add a "class='selected'" to the current list item. EDIT: don't know why, but when installing this, I get an error 500 in every page except of the CMS pages, which works fine. I'm using Prestashop 1.4.8.2 Edited October 16, 2012 by rafamerida (see edit history) Link to comment Share on other sites More sharing options...
rafamerida Posted December 19, 2012 Share Posted December 19, 2012 Hi again, Tarek! Finally I managed to upgrade my site to 1.5.1 and your module was working well, but didn't noticed that when I activate your module, I lose some search functions. In detail, when your module is active, the pagination of every search-result page, doesn't link well. Every button at the pagination part has a link like this: index.php?controller=cms?tag=XXXXXX&p=2 index.php?controller=cms?tag=XXXXXX&p=3 when it should be: search?tag=XXXXXX&p=2 search?tag=XXXXXX&p=2 ...and I get a 404 page, my visitors only can see the first page when they search. Have tested and isolated the problem, the only module that is pulling this error is this one (yours) Your help would be MUCH appreciated. Link to comment Share on other sites More sharing options...
malorie Posted October 21, 2015 Share Posted October 21, 2015 Bonjour, Ton développement fonctionne-t-il dans PS 1.6 ? Merci d'avance de ta réponse. Link to comment Share on other sites More sharing options...
tarek.fellah Posted October 21, 2015 Author Share Posted October 21, 2015 1 million thanks Tarek, it worked perfect for me! Do you now how could I highlight the current page <li><a> in that block? I mean to add a "class='selected'" to the current list item. EDIT: don't know why, but when installing this, I get an error 500 in every page except of the CMS pages, which works fine. I'm using Prestashop 1.4.8.2 Hi, It might be too late, You should activate the DEV_MODE to see the errors 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