Jump to content

List of sub-categories on home?


Mike Goodstadt
 Share

Recommended Posts

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

Share this post


Link to post
Share on other sites

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)

  • Like 2

Share this post


Link to post
Share on other sites

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 ;)

Share this post


Link to post
Share on other sites

  • 2 weeks later...

...

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

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More