Jump to content

Categories and subcategories and more


Recommended Posts

Hello everyone. For weeks now I try to change some things about PrestaShop but I'm going crazy. I hope someone can help me.
The problem is the management of categories and subcategories and one more thing
Some screenshots.
Thanks.

22569_XyA3Fo8X9iyjPvcyPyzO_t

22570_Nkk7DlbHORrfoNtgbFKo_t

22571_eESZ5jg0OyCz1lJZtvTd_t

  • Like 1
Link to comment
Share on other sites

1. Edit category.tpl in your theme's directory and {* comment out *} lines 20-24:

{else}
   <!-- Category image -->
   {if $category->id_image}
       <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" />
   {/if}



2. Copy modules/blockcategories/category-tree-branch.tpl into your theme's directory so it becomes themes/yourtheme/modules/blockcategories/category-tree-branch.tpl, then change line 2 from:

<a href="{$node.link|escape:htmlall:'UTF-8'}" {if $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|escape:htmlall:'UTF-8'}">{$node.name|escape:htmlall:'UTF-8'}



to:

<a href="{$node.link|escape:htmlall:'UTF-8'}" {if $node.id == $currentCategoryId}class="selected"{/if}{* title="{$node.desc|escape:htmlall:'UTF-8'}"*}>{$node.name|escape:htmlall:'UTF-8'}



3. I think adding the following code to css/global.css in your theme's directory should work:

div.cat_desc { text-align: justify }



It is not possible to display the subcategory thumbnails on the homepage without doing some hacking. For example, you can back up index.php and then copy the following into index.php:

<?php

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');

//will be initialized bellow...
if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
   $rewrited_url = null;

/* CSS ans JS files calls */
$css_files = array(__PS_BASE_URI__.'css/jquery.cluetip.css' => 'all', _THEME_CSS_DIR_.'scenes.css' => 'all');

include(dirname(__FILE__).'/header.php');
include(dirname(__FILE__).'/product-sort.php');

$errors = array();

$category = new Category(1, intval($cookie->id_lang));
if (!Validate::isLoadedObject($category))
   $errors[] = Tools::displayError('category does not exist');
elseif (!$category->checkAccess(intval($cookie->id_customer)))
   $errors[] = Tools::displayError('you do not have access to this category');
else
{
   /* rewrited url set */
   $rewrited_url = $link->getCategoryLink($category->id, $category->link_rewrite);

   /* Scenes  (could be externalised to another controler if you need them */
   $smarty->assign('scenes', Scene::getScenes(intval($category->id), intval($cookie->id_lang), true, false));

   /* Scenes images formats */
   if ($sceneImageTypes = ImageType::getImagesTypes('scenes'))
   {
       foreach ($sceneImageTypes AS $sceneImageType)
       {
           if ($sceneImageType['name'] == 'thumb_scene')
               $thumbSceneImageType = $sceneImageType;
           elseif ($sceneImageType['name'] == 'large_scene')
               $largeSceneImageType = $sceneImageType;
       }
       $smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
       $smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
   }

   $category->name = Category::hideCategoryPosition($category->name);
   $category->description = nl2br2($category->description);
   $subCategories = $category->getSubCategories(intval($cookie->id_lang));
   $smarty->assign('category', $category);
   if (Db::getInstance()->numRows())
       $smarty->assign('subcategories', $subCategories);
   if ($category->id != 1)
   {
       $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true);
       include(dirname(__FILE__).'/pagination.php');
       $smarty->assign('nb_products', $nbProducts);
       $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay);
   }
   $smarty->assign(array(
       'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL,
       'id_category' => intval($category->id),
       'id_category_parent' => intval($category->id_parent),
       'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)),
       'path' => ''
   ));
}

$smarty->assign(array(
   'allow_oosp' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
   'suppliers' => Supplier::getSuppliers(),
   'errors' => $errors));

if (isset($subCategories))
   $smarty->assign(array(
       'subcategories_nb_total' => sizeof($subCategories),
       'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));

$smarty->display(_PS_THEME_DIR_.'category.tpl');

include(dirname(__FILE__).'/footer.php');

?>

Link to comment
Share on other sites

  • 9 months later...

Hello,

Please help!

I want to show sub of sub category on category page when parent category display. Please see this thread

http://www.prestashop.com/forums/viewthread/89058/

I have search this for weeks, make thread in forum, ask to some people (include the prestashop team by quote on this web), but still no answer yet. Please, if somebody could help.

I use prestashop 1.3.4. It doesn't matter for me if this will change the prestashop core.

Thanks

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...