Subcategories display in main category

Hello friends,

I am changing my category page and want to display the subcategories from the subcategories on the main category.

See the image below to understand this:

This is my code:


{foreach from=$subcategories item="category"}
{if $category}




{split data=$subcategories size=$columns|default:"2" assign="splitted_categories"}
{math equation="floor(100/x)" x=$columns|default:"2" assign="cell_width"}

{foreach from=$splitted_categories item="subcategories"}

{assign var=darin value=$category.category_id}
$smarty_var = $this->get_template_vars('darin');
$cat_var = fn_get_image_pairs($smarty_var, 'category', 'M', true, false);
$this->assign('category_image', $cat_var);

{if empty($category_image.icon.image_path)}

// The sub-subcategories should come here... //



As you can see there is half way a empty space that is reserved for the sub-subcategories.

Can someone help me with this? I would be very grateful.

Thanks in advance,