Jump to content

Recommended Posts

I'd like to show under category-count siblings subcategories. I have found one solution but it doesn't work for me. 

 

category-count.tpl:

<!-- Subcategories -->
{if isset($subcategories) }
<ul>
{foreach from=$subcategories item=subcategory}
<li>
<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
</li>
{/foreach}
</ul>




{else if $category->active}
<ul>
{foreach from=$category_siblings item=siblingcategory}
<li>
{$siblingcategory.name}
</li>
{/foreach}
</ul>
{else} ZLE PODMIENKY
{/if}
 
CategoryController:
<?php


class CategoryController extends CategoryControllerCore
{
public function displayContent()
    {
        // Get the global smarty object.
        global $smarty;


        // Get current category's parent.
        $parent_category = new Category($this->category->id_parent, self::$cookie->id_lang);


        // Get parent category's subcategories (which is current category's siblings, including it self).
        $category_siblings = getChildren($parent_category,self::$cookie->id_lang,true);


        /* Assign your siblings array to smarty. */
        $smarty->assign(
            array(
                "category_siblings" => $category_siblings
            )
        );


        /* This we run the normal displayContent, but pass the siblings array to
           category.tpl */
        parent::displayContent();
    }
}

 

Link to comment
Share on other sites

{if isset($subcategories) }
<ul>
{foreach from=$subcategories item=subcategory}
<li>
<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'}</a>
</li>
{/foreach}
</ul>
{/if}


try to use only thins

after modification don't forget to clear shop cache! (it's better to disable it and to turn force compile on while you work on your template)

Link to comment
Share on other sites

  • 2 months later...

I really would like to do the same thing. But I can't get it to work.

 

Is there anything else that needs to be done to make this work?

 

 

In controllers/front i already have this CategoryController.php

<?php

class CategoryController extends CategoryControllerCore
{

public function initContent()
	{
		parent::initContent();
		/************************* Images Array ******************************/
		if(method_exists('Product','getProductsImgs'))
		{
		$image_array=array();
		for($i=0;$i<count($this->cat_products);$i++)
		{
			if(isset($this->cat_products[$i]['id_product']))
				$image_array[$this->cat_products[$i]['id_product']]= Product::getProductsImgs($this->cat_products[$i]['id_product']);
		}
		$this->context->smarty->assign('productimg',(isset($image_array) AND $image_array) ? $image_array : NULL);
		}
		/************************* /Images Array ******************************/
		
	}


}

Should I change that some how or should the new CategoryController just be placed in /controllers?

 

Thanks in advance

Edited by stejob (see edit history)
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...