On finalise le module mesCategories

This commit is contained in:
2020-10-26 19:17:37 +01:00
parent e22e5da764
commit 7b6714806c
18 changed files with 256 additions and 550 deletions

View File

@@ -223,16 +223,35 @@ class MesCategories extends Module
public function hookDisplayHome()
{
$categories = Category::getHomeCategories((int)$this->context->language->id, true);
$lang_id = (int)$this->context->language->id;
$my_array = array();
$categories = Category::getHomeCategories($lang_id, true);
foreach ($categories as $category) {
if (Category::hasChildren($category[id_category], (int)$this->context->language->id, true)) {
$children = Category::getChildren($category[id_category], (int)$this->context->language->id, true);
array_push($subcategories, [$children]);
$array_category = array (
'category_id' => $category[id_category],
'category_name' => $category[name],
'category_img' => $category[name]
);
if (Category::hasChildren($category[id_category], $lang_id, true)) {
$subcategories = Category::getChildren($category[id_category], $lang_id, true, true);
$array_subcategories = array();
foreach ($subcategories as $subcategory) {
$array_subcategory = array(
'subcategory_name' => $subcategory[name],
'subcategory_id' => $subcategory[id_category],
'subcategory_link' => $subcategory[link_rewrite]);
array_push($array_subcategories, $array_subcategory);
}
$array_category['subcategories'] = $array_subcategories;
array_push($my_array, $array_category);
}
}
$this->smarty->assign(array(
'categories' => $categories,
'sub-categories' => $subcategories,
'categories' => $my_array
));
return $this->display(__FILE__, 'displayHome.tpl');
@@ -240,11 +259,11 @@ class MesCategories extends Module
public function hookDisplayHomeTab()
{
/* Place your code here. */
return $this->hookDisplayHome();
}
public function hookDisplayHomeTabContent()
{
/* Place your code here. */
return $this->hookDisplayHome();
}
}

View File

@@ -1,27 +1,53 @@
/**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
/* Container principal */
#mesCategories {
margin-top: 30px;
display: inline-flex;
width: 100%;
justify-content: space-evenly;
align-items: flex-start;
text-align: center;
}
/* Sous-catégories (liens hypertexte) */
.subcategory {
display: flex;
width: 160px;
align-items: center;
}
.category-image {
}
/* Catégorie (image + titre) */
.figure img {
width: 150px;
border-radius: 5px;
opacity: 0.25;
}
.figure figcaption {
margin-bottom: 10px;
font-family: "Raleway", sans-serif;
font-weight: bolder;
color: black;
}
.subcategories-list {
margin-left: -145px;
line-height: 1.7rem;
z-index: 3;
text-align: center;
}
.subcategories-list a {
font-size: 0.95rem;
font-family: "Raleway", sans-serif;
color: black;
width: 100%;
}
.subcategories-list a:hover {
font-weight: bold;
}

View File

@@ -1,27 +1,25 @@
<!-- Block mesCategories -->
<div id="mesCategories_bloc_principal" class="block">
<ul id="categories-slider">
<div>
<ul id="mesCategories">
{foreach from=$categories item=category name=category_list}
<li>
categorie : {$category.name}
{if $category.image.large.url}
<div class="category-cover">
<img src="{$category.image.large.url}" alt="{if !empty($category.image.legend)}{$category.image.legend}{else}{$category.name}{/if}">
<div class="subcategory">
<div class="category-image">
<figure class="figure">
<figcaption>{$category.category_name}</figcaption>
<img src="{$urls.base_url}img/c/{$category.category_id}.jpg" alt="{$category.category_name|escape:'html':'UTF-8'}" />
</figure>
</div>
{/if}
<div id="subcategories">
<ul class="clearfix">
{foreach from=$subcategories item=subcategory}
<li class="col-xl-2 col-sm-3 col-xs-4">
<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}" title="{$subcategory.name|escape:'html':'UTF-8'}" class="img">
<img src="{$subcategory.image.large.url}" alt="{if !empty($subcategory.image.legend)}{$subcategory.image.legend}{else}{$subcategory.name}{/if}">
</a>
<a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">
{$subcategory.name|truncate:125:'...'|escape:'html':'UTF-8'}
</a>
</li>
<div class="subcategories-list">
{foreach from=$category.subcategories item=subcategory name=subcategory_list}
<a href="{$link->getCategoryLink($subcategory.subcategory_id, $subcategory.subcategory_link)|escape:'html':'UTF-8'}"
title="{$subcategory.subcategory_name|escape:'html':'UTF-8'}">
{$subcategory.subcategory_name|escape:'html':'UTF-8'}
</a><br />
{/foreach}
</ul>
</div>
</div>
</li>
{/foreach}