From 49cd82d3df34fec306014ce92877b25f3e696727 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 14 Nov 2017 15:48:24 +0100 Subject: [PATCH] Rewrite --- modules/purchaseguide/classes/GuideCategory.php | 13 ++++++++++++- .../controllers/front/PostController.php | 12 ++---------- modules/purchaseguide/purchaseguide.php | 15 +++++++-------- .../views/templates/front/content.tpl | 4 +++- .../views/templates/hook/leftcolumn.tpl | 13 ++++++++++++- .../views/templates/hook/topmenulink.tpl | 2 +- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/modules/purchaseguide/classes/GuideCategory.php b/modules/purchaseguide/classes/GuideCategory.php index 8a5a468a..389a9be6 100644 --- a/modules/purchaseguide/classes/GuideCategory.php +++ b/modules/purchaseguide/classes/GuideCategory.php @@ -340,7 +340,7 @@ class GuideCategory extends ObjectModel foreach ($result as $c) { $rewrite = 'guide/'; if ($c['id_parent'] != 0) { - $parent = $this->getParent($c['id_guide_category'], $id_lang); + $parent = $this->getParent($c['id_parent'], $id_lang); $rewrite.= $parent['link_rewrite'].'/'; } $rewrite.= $c['id_guide_category'].'-'.$c['link_rewrite']; @@ -358,6 +358,12 @@ class GuideCategory extends ObjectModel return $data; } + /** + * Get Parent category + * @param int $id_category + * @param int $id_lang + * @return array + */ public function getParent($id_category, $id_lang) { $sql = "SELECT gc.*, gcl.name, gcl.link_rewrite @@ -369,6 +375,11 @@ class GuideCategory extends ObjectModel return $result; } + /** + * Gest All main categories + * @param int $id_lang + * @return array + */ public static function getRoot($id_lang) { $sql = "SELECT gc.id_guide_category, gcl.name, gcl.link_rewrite, gcl.meta_title, diff --git a/modules/purchaseguide/controllers/front/PostController.php b/modules/purchaseguide/controllers/front/PostController.php index 1b4382b8..a2cc7437 100644 --- a/modules/purchaseguide/controllers/front/PostController.php +++ b/modules/purchaseguide/controllers/front/PostController.php @@ -4,16 +4,6 @@ require_once(__DIR__.'/../../classes/GuidePost.php'); class PostController extends FrontController { - private function getPath() - { - $pipe = Configuration::get('PS_NAVIGATION_PIPE'); - if (empty($pipe)) { - $pipe = '>'; - } - - return "Guide > "; - } - public function canonicalRedirection() {} public function preProcess() @@ -131,6 +121,8 @@ class PostController extends FrontController 'postTitle' => $content['meta_title'], 'postContent' => $content['content'], 'postLink' => '', + + 'id_guide_post_select' => $id_post, )); $metaTags = Tools::completeMetaTags(array( diff --git a/modules/purchaseguide/purchaseguide.php b/modules/purchaseguide/purchaseguide.php index e34a9b1e..db9b4a5d 100644 --- a/modules/purchaseguide/purchaseguide.php +++ b/modules/purchaseguide/purchaseguide.php @@ -255,7 +255,7 @@ class PurchaseGuide extends Module $rewrite = $category->getLinkRewrite($cookie->id_lang); $smarty->assign(array( - 'link_rewrite' => $rewrite, + 'link_rewrite' => '/guide/'.$rewrite, )); return $this->display(dirname(__FILE__), '/views/templates/hook/topmenulink.tpl'); @@ -265,19 +265,18 @@ class PurchaseGuide extends Module { global $cookie, $smarty; - // id_category, id_subcategory + // id_category $id_category = Tools::getValue('cid', 0); - $id_subcategory = Tools::getValue('sid', 0); - - /*if ($id_category == 0) { - return ''; - }*/ + // @todo : id_category2 // Récup de l'arbre en fonction des catégories $model = new GuideCategory(); $tree = $model->getTree($cookie->id_lang); - + + // @todo : id_guide_category_select, id_guide_post_select $smarty->assign(array( + 'id_guide_category_select_main' => $id_category, + 'id_guide_category_select_second' => $id_category, 'menu' => $tree, )); diff --git a/modules/purchaseguide/views/templates/front/content.tpl b/modules/purchaseguide/views/templates/front/content.tpl index 077ca82d..cdd310f0 100644 --- a/modules/purchaseguide/views/templates/front/content.tpl +++ b/modules/purchaseguide/views/templates/front/content.tpl @@ -19,7 +19,9 @@
diff --git a/modules/purchaseguide/views/templates/hook/leftcolumn.tpl b/modules/purchaseguide/views/templates/hook/leftcolumn.tpl index 7d47387b..7b2338d4 100644 --- a/modules/purchaseguide/views/templates/hook/leftcolumn.tpl +++ b/modules/purchaseguide/views/templates/hook/leftcolumn.tpl @@ -1,6 +1,17 @@
{foreach from=$menu item=c} -

{$c.name}

+ {assign var="isSelected" value="0"} + {if $c.id_guide_category} + {assign var="isSelected" value="1"} + {/if} +

{$c.name}

+ + {if $c.children|@count > 0 && $isSelected==0} + {foreach from=$c.children item=children} + + {/foreach} + {/if} + {if $c.children|@count > 0}