menegonfabio Posted July 20, 2021 Share Posted July 20, 2021 (edited) 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 July 21, 2021 by menegonfabio (see edit history) Link to comment Share on other sites More sharing options...
SmartDataSoft Posted July 20, 2021 Share Posted July 20, 2021 Do you have any sample picture how you like to do. It will clear to us. To give a better solution Thank you Link to comment Share on other sites More sharing options...
menegonfabio Posted July 20, 2021 Author Share Posted July 20, 2021 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 Link to comment Share on other sites More sharing options...
SmartDataSoft Posted July 20, 2021 Share Posted July 20, 2021 @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 1 Link to comment Share on other sites More sharing options...
menegonfabio Posted July 21, 2021 Author Share Posted July 21, 2021 @SmartDataSoft It worked great !! I had to change from 3 to 4, but this is a detail that depends on the situation. Thank you very much! Link to comment Share on other sites More sharing options...
menegonfabio Posted July 23, 2021 Author Share Posted July 23, 2021 @SmartDataSoft Is it possible to do the same but with a cycle that counts all the sub-categories and adds the table to the last sub-category? Because it may happen that categories are added in the future and I would like to avoid changing the .tpl file every time. Thank you Link to comment Share on other sites More sharing options...
SmartDataSoft Posted July 23, 2021 Share Posted July 23, 2021 @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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now