PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

 

[SOLVED] Categories

21 replies to this topic
#1
Papaya

    PrestaShop Apprentice

  • Members
  • PipPip
  • 70 posts
Hope someone can help me...

I just want to create a page like this: http://www.wowo.fr/97-20-euros

If I go to Shoes I want to find this:

Shoes:
Running
Boots
Heels


and not go to the Shoes category and see the other categories too!

-Shoes: 
Running
Boots
Heels

-T-shirt
-Skirt


How can I do this?

Thanks!

#2
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
Try changing lines 9-13 of modules/blockcategories/blockcategories.tpl from:


{if $smarty.foreach.blockCategTree.last}
{include file=$branche_tpl_path node=$child last='true'}
{else}
{include file=$branche_tpl_path node=$child}
{/if}


to:


{if $smarty.foreach.blockCategTree.last}
{include file=$branche_tpl_path node=$child depth=1 last='true'}
{else}
{include file=$branche_tpl_path node=$child depth=1}
{/if}


then change modules/blockcategories/category-tree-branch.tpl to:


{assign var='childSelected' value='0'}
{foreach from=$node.children item=child}{if $child.id == $smarty.get.id_category}{assign var='childSelected' value='1'}{/if}{/foreach}
{if $page_name != 'category' OR $depth != 1 OR $node.id == $smarty.get.id_category OR $childSelected}

  • {$node.name|escape:html:'UTF-8'}
    {if $node.children|@count > 0}

      {foreach from=$node.children item=child name=categoryTreeBranch}
      {if $smarty.foreach.categoryTreeBranch.last}
      {include file=$tpl_dir./category-tree-branch.tpl node=$child depth=$depth+1 last='true'}
      {else}
      {include file=$tpl_dir./category-tree-branch.tpl node=$child depth=$depth+1 last='false'}
      {/if}
      {/foreach}

    {/if}

  • {/if}


    This should do what you want as long as the category depth is no more than 2.
    Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

    #3
    Papaya

      PrestaShop Apprentice

    • Members
    • PipPip
    • 70 posts
    Thanks Rocky!!!

    This is what I want!!!!! I have already tried and it works!!!!

    Thank you so much Rocky!!!

    #4
    BillyD

      PrestaShop Newbie

    • Members
    • Pip
    • 9 posts
    Thanks your subcategory fix is working well, however when I click on a product in a subcategory, the product.php page loads and I loose my "subcategory only" listing from the Category Block?

    #5
    sandipk

      PrestaShop Newbie

    • Members
    • Pip
    • 1 posts
    Thanks your subcategory fix is working well, however when I click on a product in a subcategory, the product.php page loads and I loose my “subcategory only” listing from the Category Block?

    #6
    nilady

      PrestaShop Apprentice

    • Members
    • PipPip
    • 66 posts
    how about if when clicks one of the category : example accessoris-earing and the view is all the product in list without see the categories again, how to do it?

    #7
    imsocial

      PrestaShop Newbie

    • Members
    • Pip
    • 6 posts
    Im sorry to bring up an old thread. But like the previous 2 comments have said. This only works in the category page. How would I get it to keep the same format in the product page and others?

    Thanks

    #8
    mel-

      PrestaShop Apprentice

    • Members
    • PipPip
    • 81 posts
    I couldn't get this to work at all. the theme I have is using a dhtml menu. is that why? I am using 1.3. thanks.

    #9
    johny2k

      PrestaShop Newbie

    • Members
    • Pip
    • 23 posts
    Dear Rocky, sorry for head up this issue again. Because I have been try the solution as you provide, then I still found that it still have some problem.

    1. When I click the main categories mobile phone (picture cate01.jpg), then left column categories place will show Mobile Phone > BlackBerry & HTC. (picture cate01.jpg)

    2. When I click the sub categorie which Mobile Phone > BlackBerry (picture cate02.jpg), then left column categories will only show Categories Mobile Phone, no more show as Mobile Phone > BlackBerry & HTC (picture cate03.jpg).

    Hope you can provide help again, thanks a lot Rocky.

    Regards,
    John

    Attached Files



    #10
    rocky

      PrestaShop Superstar

    • US Moderators
    • 9988 posts
    My AJAX Sliding Categories module has the option to display just the subcategories of the current category and has many more options. It is hard to justify sifting through my code and extracting just the part that does this.
    Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

    #11
    pldtm

      PrestaShop Apprentice

    • Members
    • PipPip
    • 36 posts
    hi rocky,

    your solution works fine for me, but i have just one question.

    Is it possible to have the option to hide all categories when they are not selected (for example when you are on the homepage no categories are selected and so no categories have to be visible.

    thanks a lot


    pldtm

    #12
    rocky

      PrestaShop Superstar

    • US Moderators
    • 9988 posts
    You could add code like the following to the top of modules/blockcategoriesnc/blockcategoriesnc.tpl:


    {if $page_name != 'index'}


    and the following at the bottom:


    {/if}


    This will hide the category block altogether on the homepage.
    Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

    #13
    Don Camillo

      PrestaShop Apprentice

    • Members
    • PipPip
    • 91 posts
    Hi,
    I asked my question in a different post, but I think you guys know what to do... PLEASE HELP!

    When I take the steps as written on page 1, I have this, for example;


    (Categoryblock1):boxershorts

    boxershorts A
    boxershorts B
    boxershorts C
    (+)t-shirts: t-shirt A, t-shirt B, t-shirt C (<-- subcategory with ID as used in step 4 of page1, permanently visable. And unfolding when clicking in Category2. I want this not showing up here, only in category2block).
    boxershort D
    boxershort E


    (Categoryblock2):t-shirts

    t-shirt A
    t-shirt B
    t-shirt C


    As you can see my second categoriesblock appears also as a subcategory in between other products in category1.
    I tried a lot of ways, but this is the only way I can get it done.
    How can I just make 2 categories; cat.1 for only product A, and cat.2 for only product B. (not showing B at A)?

    Can anyone help me please? I tried everything I know, maybe its in the php files?

    Thanks in advance!
    Grtz, Don C.

    #14
    tip98

      PrestaShop Newbie

    • Members
    • Pip
    • 2 posts
    @rocky
    thanks for help! Your post http://www.prestasho...post__p__321549 is great and it helped me much. But there is one little issue related more to this forum than to your code. Code snippet in this forum is stripping your code from ul's and li's html tags so sometimes is hard to understand it for the first time.

    One more thing: when I go to product page all categories are visible like in standard blockcategories. It is possible to get same effect in product page like in category and product-list pages?

    edit:

    I've figured it out myself.

    I've changed:

    {foreach from=$node.children item=child}{if $child.id == $smarty.get.id_category}{assign var='childSelected' value='1'}{/if}{/foreach}
    {if $page_name != 'category' OR $depth != 1 OR $node.id == $smarty.get.id_category OR $childSelected}


    to

    {foreach from=$node.children item=child}{if $child.id == $currentCategoryId}{assign var='childSelected' value='1'}{/if}{/foreach}
    {if $depth != 1 OR $node.id == $currentCategoryId OR $childSelected}

    and now itis working both in categories and in product pages.

    btw I'm using v 1.3.1

    Edited by tip98, 21 August 2011 - 03:37 PM.


    #15
    andresdez

      PrestaShop Newbie

    • Members
    • Pip
    • 3 posts
    Sorry, but I don't know how to proceed to change the category-tree-branc.tpl. Actually I am using the version 1.4 and the code inside is:




    <li {if isset($last) && $last == 'true'}class="last"{/if}>

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

    {if $node.children|@count > 0}

    <ul>

    {foreach from=$node.children item=child name=categoryTreeBranch}

    {if isset($smarty.foreach.categoryTreeBranch) && $smarty.foreach.categoryTreeBranch.last}

    {include file="$branche_tpl_path" node=$child last='true'}

    {else}

    {include file="$branche_tpl_path" node=$child last='false'}

    {/if}

    {/foreach}

    </ul>

    {/if}

    </li>


    I replace this code by the one you write, and it doesn't work...I am doing something wrong?

    Thanks in advance

    #16
    anil@adodis.com

      PrestaShop Newbie

    • Members
    • Pip
    • 4 posts
    Hi Rocky,

    thanks for u r continuous support for the new users in Prestashop, Iam very new to prestashop and am using version 1.4.1 now i have an issue regarding displaying the categories, the thing is that i want to display only active Category (the one i have selected) and its Subcategories in my page and other categories should not be displayed is that possible and please brief me all the steps in respective files to do the needed changes that will help me a lot.

    Anil
    Bangalore

    #17
    rob84

      PrestaShop Newbie

    • Members
    • Pip
    • 5 posts
    I have a problem with a 3th level category: a > b > c > product list . When I click on "c" category, simply disappear all categories, nothing are loaded. Can someone help for that ? Otherwise great mod.

    Thanks,
    Robert

    #18
    dawb

      PrestaShop Newbie

    • Members
    • Pip
    • 24 posts
    Hi,

    I have managed to get this working in 1.5 by replacing file=$tpl_dir./category-tree-branch.tpl with file="$branche_tpl_path", but am having issues where if you are on the product page it displays all subcategories it belongs to eg:

    cat 1
    - sub cat 1
    - sub cat 2

    cat 2
    -sub cat1

    Does anyone know how to resolve this? Also having an issue where the menu is not showing at all if you are on one of the sub category pages. Thanks for your help

    #19
    maricarmen

      PrestaShop Newbie

    • Members
    • Pip
    • 17 posts
    Hi,
    File code "category-tree-branch.tpl" for version 1.4, how would it be?
    Thanks

    #20
    luconelucone

      PrestaShop Newbie

    • Members
    • Pip
    • 18 posts

    View Postrob84, on 27 October 2011 - 01:55 AM, said:

    I have a problem with a 3th level category: a > b > c > product list . When I click on "c" category, simply disappear all categories, nothing are loaded. Can someone help for that ? Otherwise great mod. Thanks, Robert
    Hi, have you find a solution??
    I have the same problem!

    I try to set max depth, but it doesn't work!
    Help!