Abdul Posted September 9, 2018 Share Posted September 9, 2018 (edited) Hi, i am new to prestashop and using prestashop 1.7. I wanna show one parent category with its sub categories data/information into another parent category page in category.tpl file. I have created frontcontroller public static function getCategoryName($id){ $category = new Category ($id,Context::getContext()->language->id); return $category->name; } and displaying category name by id {FrontController::getCategoryName(273)} 273 is category id. now i can not find the way to show sub categories and their cover images of category id 273 Edited September 9, 2018 by Abdul (see edit history) Link to comment Share on other sites More sharing options...
Knowband Plugins Posted September 9, 2018 Share Posted September 9, 2018 Hi, Use getChildren() function to retrieve the sub-categories of a category. Refer to Category.php file inside the classes folder to check the details of the funcation. getChildren(273, Context::getContext()->language->id); Link to comment Share on other sites More sharing options...
Abdul Posted September 11, 2018 Author Share Posted September 11, 2018 not displaying anything can you guide me how could i use this code in .tpl file Link to comment Share on other sites More sharing options...
Knowband Plugins Posted September 18, 2018 Share Posted September 18, 2018 To display the same in .tpl file, you need to assign the variable from the controller file. This function can't be called directly into tpl. In the controller, write the code like. $subcategories = getChildren(273, Context::getContext()->language->id); $this->conext->smarty->assign('subcategories', $subcategories); In the tpl file, you can access the subcategories using the variable {$subcategories} but you need to run a loop in the tpl to display the subcategories. 1 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