Jump to content

How to add categories on homepage?


Recommended Posts

As in topic. I would like to write it by myself or some free plugin but I haven't found such.

What files should I edit? I think it shouldn't be that difficult. I think that I should somehow pass Categories variable to smarty index.tpl template file.

 

Do you have any suggestions or hints?

Link to comment
Share on other sites

  • 2 weeks later...

Did you look to put links to categories on your home page ?? Or ??

 

I am thinking to do teh same by adding some categories in the bottom of the features products module.

 

This is just for SEO as my menu bar is collapsing too soon.

 

Not sure if that helps, but you can change the featured product module to do so. 

Link to comment
Share on other sites

I suppose it's not professional but I've made it this way: In indexController.php added

$db = new PDO('mysql:dbname='._DB_NAME_.';host='._DB_SERVER_.';charset=utf8',_DB_USER_,_DB_PASSWD_);
        $stmt = $db->prepare('SELECT ps_category.*, ps_category_lang.name, ps_category_lang.link_rewrite FROM ps_category INNER JOIN ps_category_lang ON ps_category.id_parent=2 AND ps_category.id_category=ps_category_lang.id_category');
        $stmt->execute();
        $categories = $stmt->fetchAll(PDO::FETCH_ASSOC);
'categories' => $categories

and in index.tpl

{if isset($categories)}
  {foreach from=$categories item=category name=fe}
     <a class="category-link-wrapper" href="{$base_dir}{$category.id_category}-{$category.link_rewrite}">
     <div class="img-wrapper">
       <div style="background: url({$base_dir}c/{$category.id_category}-category_default/{$category.link_rewrite}.jpg) no-repeat scroll center center;width:100%;height: 100%" alt=""></div>
     </div>
     <div class="link-wrapper">{$category.name}</div></a>
  {/foreach}
{/if}
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...