TIP: Show all categories at the same level as current category

I had the need to show all categories at the same level of the current categories and thought it might be helpful to someone else so heres the tip.

Example: If the customer is browsing Apparel category and clicks Shirts there are no more sub categories under Shirts but they might want to go to another sub category of Apparel. This tip makes it possible to provide this information to the customer via links or whatever you prefer.

create file addons//my_changes/controllers/customer/categories.post.php and this code:

<br />
<?php<br />
if ($mode == 'view') {<br />
$sub_categories = $view->get_var('subcategories');<br />
$category_id = $view->get_var('$category_data');<br />
$category_data = $view->get_var('category_data');<br />
<br />
if (! $sub_categories)<br />
{<br />
  $subcat = $view->get_var('subcategories');<br />
<br />
		 $subcat = fn_get_subcategories($category_data[parent_id]);<br />
         foreach($subcat as $k => $v) {<br />
             $subcat[$k]['main_pair'] = fn_get_image_pairs($v['category_id'], 'category', 'M', true, true);<br />
        }<br />
		 $view->assign('parent_subcategories', $subcat);<br />
}<br />
}<br />
?><br />

```<br />
<br />
now from within any template file you can refer to the variable parent_subcategories and use something like this to loop through the categories.<br />
<br />
<br />
<br />
{if $subcategories}<br />
{foreach from=$parent_subcategories item="subcategory"} <br />
<a href="{$index_script|fn_url}">{$subcategory.category}&nbsp;</a><br/><br />
{/foreach}<br />
{/if}<br />