Jump to content

[SOLVED]Categories on homepage


Recommended Posts

I have been scouring the forums for a way to show categories on the homepage, but I have only found a module into which you have to hard code the categories and subcategories which seems a little pointless.

I intend to copy the homefeatured module, renaming it homecategories (as I am using the homefeatured mosule, so don't want to override it.) and edit it to show categories instead - I figure this is the easiest way (simply switch from products to categories)?

However, I don't know how to edit the files to show categories - so far I just have a duplicate of Home Featured!

I want to show the category title, image, description with links to the category and also links to the subcategories.

How do I go about this?

Link to comment
Share on other sites

OK, so I found this module: http://www.quaycreative.com/news/article/category-on-the-homepage-module-free-module-for-prestashop-user/ which shows me how to show the categories with the description.

Now the last piece of the puzzle is showing the subcategories (just a simple list of links below each category will do).

Any ideas? I have tried all sorts, but I don't really know what I'm doing!

Link to comment
Share on other sites

  • 1 month later...

Well at the moment I have abandoned that module to start afresh by copying the blockcategories module. So far, I can add teh top category description by editing category-tree-branch.tpl to simply include this line:

 {$node.desc|escape:html:'UTF-8'}


before this:

>    {if $node.children|@count > 0}
</pre>
<ul>



now I want to add the image for that main category too. This doean't work:

getCatImageLink($category.link_rewrite, $category.id_image,'category-on-home')}" alt="{$category.name|escape:'htmlall':'UTF-8'}" />



so what do I need to do?

Link to comment
Share on other sites

Woohoo! Got it working thanks to this thread: http://www.prestashop.com/forums/viewthread/5474/integration/howto_add_category_thumbnails_in_menu_block_

I just used this for my image:




and changed this bit of code in the module php (based on blockcategories)

global $link;
       $smarty->assign(array(
           'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true),
           'link' => $link
       ));



to this:

global $link;
       $smarty->assign(array(
           'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true),
           'link' => $link,
           'homeSize' => Image::getSize('category-on-home')
       ));



I love it when a plan comes together!

Link to comment
Share on other sites

  • 1 year later...

hmm attempting to do this myself - you think blockcategories is the way forward then? As I'm at the stage of yourself where I have a duped homefeat. and am now looking to get it displaying the mofo'ing cats...! Mind if I have a look at yours to see how its come out and looks onsite?

 

Thanks.

 

EDIT: got a feeling the answer is in this:

 

$category = new Category(1, Configuration::get('PS_LANG_DEFAULT'));

 

Code taken from homepagefeatured.php

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