ericdel Posted February 5, 2012 Posted February 5, 2012 Bonjour Est-il possible de lister automatiquement toutes les pages d'une catégorie CMS lorsqu'on est sur une page faisant partie de cette catégorie ? Si on est dans la page catégorie, visiblement cette boucle issue de cms.tpl le fait : {elseif isset($category)} <div> <h1>{$category->name|escape:'htmlall':'UTF-8'}</h1> {if isset($sub_category) & !empty($sub_category)} <h4>{l s='List of sub categories in '}{$category->name}{l s=':'}</h4> <ul class="bullet"> {foreach from=$sub_category item=subcategory} <li> <a href="{$link->getCMSCategoryLink($subcategory.id_cms_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} </ul> {/if} {if isset($cms_pages) & !empty($cms_pages)} <h4>{l s='List of pages in '}{$category->name}{l s=':'}</h4> <ul class="bullet"> {foreach from=$cms_pages item=cmspages} <li> <a href="{$link->getCMSLink($cmspages.id_cms, $cmspages.link_rewrite)|escape:'htmlall':'UTF-8'}">{$cmspages.meta_title|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} </ul> {/if} </div> {else} Mais si je recopie {foreach from=$cms_pages item=cmspages} <li> <a href="{$link->getCMSLink($cmspages.id_cms, $cmspages.link_rewrite)|escape:'htmlall':'UTF-8'}">{$cmspages.meta_title|escape:'htmlall':'UTF-8'}</a> </li> {/foreach} Rien n'apparaît... Merci de votre aide, je m'arrache les cheveux ! Share this post Link to post Share on other sites More sharing options...
ericdel Posted February 5, 2012 Posted February 5, 2012 J'ai essayé avec un inclure d'appeler, à partie de ma page cms, la page cms.php?id_cms_category="l'id de la catégorie de l'article en cours" afin de récupérer un $cms_pages contenant les pages "soeurs" de la page en cours mais cela ne fonctionne pas. La page plante et reste blanche. Une idée pour remplir ce maudit $cms_pages ? J'ai exploré les fonctions de références mais cela dépasse mon niveau. Merci de votre aide ! Share this post Link to post Share on other sites More sharing options...
ericdel Posted February 6, 2012 Posted February 6, 2012 J'ai trouvé ! Si cela intéresse quelqu'un un jour : dans controllers/CMScontroller.php J'ai modifié à la ligne 100 : self::$smarty->assign(array( 'cms' => $this->cms, en ajoutant une ligne : self::$smarty->assign(array( 'cms_pages' => CMS::getCMSPages((int)(self::$cookie->id_lang), (int)($this->cms->id_cms_category) ), 'cms' => $this->cms, et donc, dans $cms_pages, je récupère toutes les pages de la même catégorie que la page courante. 2 Share this post Link to post Share on other sites More sharing options...
surflibre Posted June 15, 2014 Posted June 15, 2014 (edited) Bonjour, Merci bien vu, cela fonctionne sous 1.6, il faut aller à la ligne 112:$this->context->smarty->assign(array('cms' => $this->cms,'cms_pages' => CMS::getCMSPages((int)(self::$cookie->id_lang), (int)($this->cms->id_cms_category) ), à la limite un petit override dans override/controllers/front/CmsController.php : <?php class CmsController extends CmsControllerCore { /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $parent_cat = new CMSCategory(1, $this->context->language->id); $this->context->smarty->assign('id_current_lang', $this->context->language->id); $this->context->smarty->assign('home_title', $parent_cat->name); $this->context->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID')); if (isset($this->cms->id_cms_category) && $this->cms->id_cms_category) $path = Tools::getFullPath($this->cms->id_cms_category, $this->cms->meta_title, 'CMS'); else if (isset($this->cms_category->meta_title)) $path = Tools::getFullPath(1, $this->cms_category->meta_title, 'CMS'); if ($this->assignCase == 1) { $this->context->smarty->assign(array( 'cms' => $this->cms, 'cms_pages' => CMS::getCMSPages((int)(self::$cookie->id_lang), (int)($this->cms->id_cms_category) ), 'content_only' => (int)(Tools::getValue('content_only')), 'path' => $path, 'body_classes' => array($this->php_self.'-'.$this->cms->id, $this->php_self.'-'.$this->cms->link_rewrite) )); if ($this->cms->indexation == 0) $this->context->smarty->assign('nobots', true); } else if ($this->assignCase == 2) { $this->context->smarty->assign(array( 'category' => $this->cms_category, //for backward compatibility 'cms_category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories($this->context->language->id), 'cms_pages' => CMS::getCMSPages($this->context->language->id, (int)($this->cms_category->id), true, (int)$this->context->shop->id), 'path' => ($this->cms_category->id !== 1) ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '', 'body_classes' => array($this->php_self.'-'.$this->cms_category->id, $this->php_self.'-'.$this->cms_category->link_rewrite) )); } $this->setTemplate(_PS_THEME_DIR_.'cms.tpl'); } }?> Vider le cache >supprimer fichier cache/class_index.php Cordialement, Edited June 15, 2014 by surflibre (see edit history) 1 Share this post Link to post Share on other sites More sharing options...
isteph26 Posted October 25, 2016 Posted October 25, 2016 j'ai pas compris le but de cette manip ... en image ca dit quoi ? merci Share this post Link to post 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