Mike Goodstadt Posted August 22, 2013 Share Posted August 22, 2013 Hi all, I am writing carousel and slider modules which use categories rather than products. I need to generate a list of categories but cannot get my head around how to do this. Can anyone help?! I would struggle on but have problems at home right now and so would really appreciate assistance as my focus and clarity of reasoning this our is not 100% I can generate the first level of categories but need the sub-categories of the first main one. I would like ideally to have a module option page to select the level but that can come later... many thanks, Mike Link to comment Share on other sites More sharing options...
Mike Goodstadt Posted August 24, 2013 Author Share Posted August 24, 2013 Hi seriously - I would very much appreciate any ideas on this...?!!! Are you all on holiday ? Link to comment Share on other sites More sharing options...
vekia Posted August 24, 2013 Share Posted August 24, 2013 in php file you should use Category class - especially Category::getCategories function, it looks like: public static function getCategories($id_lang = false, $active = true, $order = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') with this function you will get list of all categories available in your store. then create a smarty array with this function return value (lis of categories). After that you will be able to use this variable in the .tpl fule (for example: in foreach lop to get each category specification) 2 Link to comment Share on other sites More sharing options...
Mike Goodstadt Posted August 25, 2013 Author Share Posted August 25, 2013 Thanks Vekia I will see if my head is clear enough today to have a second run at it... Mike Link to comment Share on other sites More sharing options...
vekia Posted August 25, 2013 Share Posted August 25, 2013 and of course you have to use Link class to create an url to the category page, something like: {$link->getCategoryLink({$id_category})} if you will have any questions - feel free to write, im lovin modifications like this so i will help with pleasure Link to comment Share on other sites More sharing options...
Amazzing Posted September 5, 2013 Share Posted September 5, 2013 ... then create a smarty array with this function return value (lis of categories) ... Can you please give the code, that creates this array? I am new to smarty, and I think I did something wrong about the syntax, so I can't get any categories variables in .tpl Link to comment Share on other sites More sharing options...
vekia Posted September 5, 2013 Share Posted September 5, 2013 Can you please give the code, that creates this array? I am new to smarty, and I think I did something wrong about the syntax, so I can't get any categories variables in .tpl what ps version you use? everything depends on it Link to comment Share on other sites More sharing options...
Amazzing Posted September 7, 2013 Share Posted September 7, 2013 what ps version you use? everything depends on it PS 1.5.4.1 Link to comment Share on other sites More sharing options...
vekia Posted September 7, 2013 Share Posted September 7, 2013 so in prestashop 1.5.x you can use this method: $this->smarty->assign('variable' => $array); 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