Jump to content

[RESOLVED] Changes to categories


menegonfabio

Recommended Posts

Hello everybody!
I am new to Prestashop, and I must admit that I know very little about PHP.
I was asked to add a table on a product page in the subcategory. The categories are divided as follows: Home / Products / Boxes / Boxes model.
Now, I was able to add the table in the desired position by working in the Category.tpl file, but the problem that I encounter, and that I cannot solve, is that in addition to putting the table in the last subcategories, it also displays it in the sub-categories previous categories.
My request is: could someone help me in making sure that the table is displayed only in the last subcategory ???
I assume I have to do a condition with a foreach in the Category.php file, but besides not understanding how to do it, I'm not sure it's the right solution.
Thanks in advance for those who will answer.

 

PrestaShop Version: 1.7.7.5

PHP Version: 7.4.21

Edited by menegonfabio (see edit history)
Link to comment
Share on other sites

Sure!
This is the final result (one of the last sub-categories where I have to view the table). The others you see in the path above do not have to show the table.

10 minutes ago, SmartDataSoft said:

Hai qualche immagine di esempio come ti piace fare. Ci sarà chiaro. Per dare una soluzione migliore

 

Grazie

 

Immagine 2021-07-20 170500.png

Link to comment
Share on other sites

@menegonfabio


This can be done with a strict way. you need to select which category depth you will show the content. Without level_depth  this is not possible to do.

If you print  {$category|print_r} in side  1.7.7.5\themes\classic\templates\catalog\_partials\category-header.tpl

then it will print 


Array ( [nleft] => 4 [nright] => 5 [level_depth] => 3 [id_parent] => 3 [id_shop_default] => 1 [is_root_category] => 0 [position] => 0 [date_add] => 2021-07-20 17:07:35 [date_upd] => 2021-07-20 17:10:30 [name] => two [link_rewrite] => two [description] =>...

after that you can use this code to show your table

 {if $category.level_depth>=3}
this is table
 {/if}

I think you are able to understand my solution and able to solve

 

Thank you

  • Thanks 1
Link to comment
Share on other sites

  • menegonfabio changed the title to [RESOLVED] Changes to categories

@menegonfabio

The things is that in category page PrestaShop do not sent it's child category list or other information other than depth. 

Their is two way we can do

1. add a custom hook where we send information of this category child or other then we will show the table

2. add a filed in admin category depending that value we will show the table

 

thank you

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...