Jump to content

Displaying sub-subcategories homepage


Recommended Posts

Hello guys i hope u can help me

Im trying to display children categories of home subcategories e.g. home subcategory is smartphone and its children are apples and samsungs 

i can do it over other site's pages but i cant do it in my homecategories module

my module is hooked to displayHome

this is php code

public function hookDisplayHome($params)
    {
        $root_cat = Category::getRootCategory($this->context->cookie->id_lang);
        $this->context->smarty->assign(
            array(
                'categories' => $root_cat->getSubCategories($this->context->cookie->id_lang)
            )
        );

        return $this->display(__FILE__, '/views/templates/hooks/homecategories.tpl');
    }

and this is the .tpl

{foreach from=$categories item=subcategory name=homeCategories}
				
				
		   
		   <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}"
                               title="{$subcategory.name|escape:'html':'UTF-8'}" class="img">
                    <li>
                        <div class="subcategory-image">
                            
                                {if $subcategory.id_image}
                                    <img class="img63"
                                         src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')|escape:'html':'UTF-8'}"
                                         alt="" width="{$mediumSize.width|escape:'htmlall':'UTF-8'}" height="{$mediumSize.height|escape:'htmlall':'UTF-8'}"/>
                                {else}
                                    <img class="replace-2x" src="{$img_cat_dir|escape:'htmlall':'UTF-8'}{$lang_iso|escape:'htmlall':'UTF-8'}-default-medium_default.jpg"
                                         alt="" width="{$mediumSize.width|escape:'htmlall':'UTF-8'}" height="{$mediumSize.height|escape:'htmlall':'UTF-8'}"/>
                                {/if}
                            
                        </div>
                        <span class="subcategory-name"
                               >{$subcategory.name|truncate:30:'...'|escape:'html':'UTF-8'}</span>
                        <div id="subcat2"></div>
                    </li>
					
				</a>
                {/foreach}

this codes just display what the module is intended to do  but i need to know if i can do what i want using this module

i would appreciate any clues about how the vars work in smarty as i never worked with this language

if u need better info just ask for it, tomorrow ill continue asking and posting my experiences

thx in advance

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
×
×
  • Create New...

Important Information

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