Breadcrumb

This commit is contained in:
Michael RICOIS 2017-11-14 11:25:17 +01:00
parent fe1dd04cf1
commit 006edad609
12 changed files with 109 additions and 58 deletions

View File

@ -315,19 +315,15 @@ class GuideCategory extends ObjectModel
return $row;
}
public function getLinkRewrite()
public function getLinkRewrite($id_lang)
{
if ($this->id) {
return $this->id.'-'.$this->link_rewrite[2];
return $this->id.'-'.$this->link_rewrite[$id_lang];
}
return '';
}
public function getLinkRewriteUrl(){}
public function getTree($id_lang, $active = 1)
{
return $this->recurseData(0, $id_lang, $active);
@ -336,15 +332,23 @@ class GuideCategory extends ObjectModel
protected function recurseData($id_category, $id_lang, $active = 1)
{
$data = array();
$sql = "SELECT gc.*, gcl.name FROM `"._DB_PREFIX_."guide_category` gc, `"._DB_PREFIX_."guide_category_lang` gcl
$sql = "SELECT gc.*, gcl.name, gcl.link_rewrite FROM `"._DB_PREFIX_."guide_category` gc, `"._DB_PREFIX_."guide_category_lang` gcl
WHERE gc.id_guide_category=gcl.id_guide_category AND gcl.id_lang=".$id_lang.
" AND gc.id_parent=".$id_category." ORDER BY position ASC";
$result = Db::getInstance()->ExecuteS($sql);
if (count($result) > 0) {
foreach ($result as $c) {
$rewrite = 'guide/';
if ($c['id_parent'] != 0) {
$parent = $this->getParent($c['id_guide_category'], $id_lang);
$rewrite.= $parent['link_rewrite'].'/';
}
$rewrite.= $c['id_guide_category'].'-'.$c['link_rewrite'];
$item = array(
'id_guide_category' => $c['id_guide_category'],
'name' => $c['name'],
'rewrite' => $rewrite,
'children' => $this->recurseData($c['id_guide_category'], $id_lang),
);
$data[] = $item;
@ -354,11 +358,26 @@ class GuideCategory extends ObjectModel
return $data;
}
public function getParent(){}
public function getMainStruct()
public function getParent($id_category, $id_lang)
{
$sql = "SELECT gc.*, gcl.name, gcl.link_rewrite
FROM `"._DB_PREFIX_."guide_category` gc, `"._DB_PREFIX_."guide_category_lang` gcl
WHERE gc.id_guide_category=gcl.id_guide_category AND gcl.id_lang=".$id_lang.
" AND gc.id_guide_category=".$id_category;
$result = Db::getInstance()->getRow($sql);
return $result;
}
public static function getRoot($id_lang)
{
$sql = "SELECT gc.id_guide_category, gcl.name, gcl.link_rewrite, gcl.meta_title,
gcl.meta_description, gcl.meta_keywords
FROM ps_guide_category gc, ps_guide_category_lang gcl
WHERE gc.active=1 AND gc.id_guide_category=gcl.id_guide_category
AND gc.id_parent=0 AND gcl.id_lang=".$id_lang;
$result = Db::getInstance()->ExecuteS($sql);
return $result;
}
}

View File

@ -176,8 +176,26 @@ class GuidePost extends ObjectModel
return '';
}
public function getLinkRewriteTree(){}
public function getUrlRewriteFull(){}
public function getCategory()
{
}
public function findByCategory($id_category, $id_lang)
{
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
WHERE gp.active=1 AND gp.id_guide_post=gpl.id_guide_post
AND gp.id_guide_category=".$id_category.
" AND gpl.id_lang=".$id_lang." ORDER BY position ASC";
$result = Db::getInstance()->ExecuteS($sql);
return $result;
}
}

View File

@ -1,4 +1,6 @@
<?php
require_once(__DIR__.'/../../classes/GuideCategory.php');
class CategoryController extends FrontController
{
public function preProcess()
@ -6,16 +8,10 @@ class CategoryController extends FrontController
parent::preProcess();
$id_lang = self::$cookie->id_lang;
$id_category = Tools::getValue('cid', 0);
$categories = array();
// Get main categories
$sql = "SELECT gc.id_guide_category, gcl.name, gcl.link_rewrite, gcl.meta_title,
gcl.meta_description, gcl.meta_keywords
FROM ps_guide_category gc, ps_guide_category_lang gcl
WHERE gc.active=1 AND gc.id_guide_category=gcl.id_guide_category
AND gc.id_parent=0 AND gcl.id_lang=".$id_lang;
$catResult = Db::getInstance()->ExecuteS($sql);
$catResult = GuideCategory::getRoot($id_lang);
if (count($catResult) > 0) {
foreach ($catResult as $c) {
$categories[] = $c;
@ -24,7 +20,6 @@ class CategoryController extends FrontController
self::$smarty->assign(array(
'path' => 'Guide',
'id_category' => $id_category,
'categories' => $categories,
));
}

View File

@ -1,8 +1,21 @@
<?php
require_once(__DIR__.'/../../classes/GuideCategory.php');
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()
{
parent::preProcess();
@ -12,7 +25,7 @@ class PostController extends FrontController
$id_category = Tools::getValue('cid', 0);
$id_post = Tools::getValue('pid', 0);
$content = null;
// Start form post
if ($id_post != 0) {
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
@ -75,7 +88,7 @@ class PostController extends FrontController
$content = Db::getInstance()->getRow($sql);
}
}
// Liste des Posts
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
WHERE gp.active=1 AND gp.id_guide_post=gpl.id_guide_post
@ -84,13 +97,25 @@ class PostController extends FrontController
$postList = Db::getInstance()->ExecuteS($sql);
$parentCategoryModel = new GuideCategory($parentCategory['id_guide_category']);
$parentCategoryLink = $parentCategoryModel->getLinkRewrite();
$parentCategoryLink = $parentCategoryModel->getLinkRewrite($id_lang);
$categoryModel = new GuideCategory($category['id_guide_category']);
$categoryLink = $categoryModel->getLinkRewrite();
$categoryLink = $categoryModel->getLinkRewrite($id_lang);
$pipe = " > ";
$path = '<a href="'.Tools::getShopDomainSsl(true).'/guide">Guide</a>'.
'<span class="navigation-pipe">'.$pipe.'</span>'.
'<a href="'.Tools::getShopDomainSsl(true).'/guide/'.$parentCategoryLink.'">'
.htmlentities($parentCategoryModel->name[$id_lang], ENT_NOQUOTES, 'UTF-8').'</a>'.
'<span class="navigation-pipe">'.$pipe.'</span>'.
'<a href="'.Tools::getShopDomainSsl(true).'/guide/'.$parentCategoryModel->link_rewrite[$id_lang].'/'.$categoryLink.'">'.
htmlentities($categoryModel->name[$id_lang], ENT_NOQUOTES, 'UTF-8').'</a>'.
'<span class="navigation-pipe">'.$pipe.'</span>'.
'<span>'.$content['meta_title'].'</span>';
self::$smarty->assign(array(
'path' => 'Guide > TODO',
'path' => $path,
'id_category' => $id_category,
'categoryTitle' => $parentCategory['name'],
'categoryLink' => $parentCategoryLink,
@ -113,7 +138,6 @@ class PostController extends FrontController
'meta_keywords' => '',
), $content['meta_title']);
self::$smarty->assign($metaTags);
}
public function displayContent()

View File

@ -252,10 +252,10 @@ class PurchaseGuide extends Module
$loadedCategory = GuideCategory::findByCategoryFamily($id_category_family, $cookie->id_lang);
$category = new GuideCategory($loadedCategory['id_guide_category']);
$rewrite = $category->getLinkRewrite();
$rewrite = $category->getLinkRewrite($cookie->id_lang);
$smarty->assign(array(
'link_rewrite' => '#',
'link_rewrite' => $rewrite,
));
return $this->display(dirname(__FILE__), '/views/templates/hook/topmenulink.tpl');

View File

@ -1,16 +1,14 @@
{include file="$tpl_dir./breadcrumb.tpl"}
<h1>Guide d'achat</h1>
<div class="rte{if $content_only} content_only{/if}">
<div class="row">
{foreach from=$categories item=c}
<div>
<div style="width:50%;float:left;text-align:center;">
<a href="guide/{$c.id_guide_category}-{$c.link_rewrite}">
<img alt="{$c.name}" src="./img/purchaseguide/{$c.id_guide_category}.jpg">
<span>{$c.meta_title}</span>
<div style="clear:both;"><span>{$c.meta_title}</span></div>
</a>
</div>
{/foreach}

View File

@ -4,7 +4,7 @@
<div class="rte{if $content_only} content_only{/if}">
<div>
<div style="width:50%; float:left;">
<div style="width:50%;float:left;">
<h2>{$subcategoryTitle}</h2>
<div>
<p>{$subcategoryContent}</p>
@ -16,7 +16,7 @@
</div>
<div class="clear">
<div style="width:24%; float:left; border:1px solid #cccccc;">
<div style="width:24%;float:left;">
<ul>
{foreach from=$postList item=p}
<li><a href="{$base_dir_ssl}guide/{$categoryRewrite}/{$subcategoryRewrite}/{$p.id_guide_post}-{$p.link_rewrite}">{$p.meta_title}</a></li>
@ -24,7 +24,7 @@
</ul>
</div>
<div style="width:75%; float:right; border:1px solid #cccccc;">
<div style="width:75%;float:right;">
<h3>{$postTitle}</h3>
<p>{$postContent}</p>
</div>

View File

@ -1,11 +0,0 @@
<div class="block-cms informations_block_left">
<h4>Vêtements</h4>
<ul class="block_content">
<li>
<a href="#">Bébés</a>
</li>
<li>
<a href="#">Enfants</a>
</li>
</ul>
</div>

View File

@ -1,10 +1,10 @@
<div class="block-cms informations_block_left">
{foreach from=$menu item=c}
<h4><a href="#">{$c.name}</a></h4>
<h4><a href="{$base_dir_ssl}{$c.rewrite}">{$c.name}</a></h4>
{if $c.children|@count > 0}
<ul class="block_content">
{foreach from=$c.children item=children}
<li><a href="#">{$children.name}</a></li>
<li><a href="{$base_dir_ssl}{$children.rewrite}">{$children.name}</a></li>
{/foreach}
</ul>
{/if}

View File

@ -1,4 +1,2 @@
<div>
<span>Besoin d'aide ?</span>
<span>Consultez notre <a href="{$link_rewrite}">Guide d'achat</a></span>
</div>
<span>Besoin d'aide ?</span><br/>
<span>Consultez notre <a href="{$link_rewrite}">Guide d'achat</a></span>

View File

@ -1900,6 +1900,12 @@ li.active .container_submenu .content_submenu {
animation-name: slideInDown;
padding: 0 15px;
}
.container_submenu .content_footer {
width: 965px;
margin: 0 auto;
position: relative;
background-color: #fff;
}
.submenu {
width: 965px;
margin: 0 auto;

View File

@ -54,14 +54,18 @@
</ul>
</div>
{$purchaseguide[$menu.id_category_family]}
</div>
<div class="content_footer">
{$purchaseguide[$menu.id_category_family]}
</div>
</div>
</div>
{/if}
</li>
{/foreach}
</ul>
</ul>
</div>
</div>