<?php
function smarty_function_newtree($params, &$smarty){
$disp='';
$disp.='<ul id="parent">';
$sql='SELECT categoryID, slug, parent, '.LanguagesManager::sql_prepareField('name').' AS name from '.CATEGORIES_TABLE. ' where parent=1 order by sort_order,name';
if($r=mysql_query($sql))
while($res=mysql_fetch_assoc($r)){
$disp.='<li class="parent';
if($_GET['categoryID'] == $res['categoryID']) $disp.='_current';
if($res['slug']!='')
$disp.='"><a href="/category/'.$res['slug'].'/">'.$res['name'].'</a>';
else
$disp.='"><a href="?categoryID='.$res['categoryID'].'">'.$res['name'].'</a>';
$disp.=subcat($res['categoryID']).'</li>';
}
$disp.='</ul>';
return $disp;
}
function subcat($parid){
$disp='';
$sql='SELECT categoryID, slug, parent, '.LanguagesManager::sql_prepareField('name').' AS name from '.CATEGORIES_TABLE. ' where parent='.$parid.' order by sort_order, name';
if($r=mysql_query($sql)){
$disp.='<ul id="child">';
while($res=mysql_fetch_assoc($r)){
$disp.='<li class="child';
if($_GET['categoryID'] == $res['categoryID']) $disp.='_current';
if($res['slug']!='')
$disp.='"><a href="/category/'.$res['slug'].'/">'.$res['name'].'</a>';
else
$disp.='"><a href="?categoryID='.$res['categoryID'].'">'.$res['name'].'</a>';
$disp.=subcatt($res['categoryID']).'</li>';
}
$disp.='</ul>';
}
return $disp;
}
function subcatt($parid){
$sql2='select parent from SC_categories where categoryID='.$_GET['categoryID'];
if($r2=mysql_query($sql2)){
$res2=mysql_fetch_assoc($r2);
$disp='';
$sql='SELECT categoryID, slug, parent, '.LanguagesManager::sql_prepareField('name').' AS name from '.CATEGORIES_TABLE. ' where parent='.$parid.' order by sort_order, name';
if($r=mysql_query($sql)){
$disp.='<ul id="children">';
while($res=mysql_fetch_assoc($r)){
if($res2['parent']==$parid || $_GET['categoryID'] == $res['parent'] ) {
$disp.='<li class="children';
if($_GET['categoryID'] == $res['categoryID']) $disp.='_current';
if($res['slug']!='')
$disp.='"><a href="/category/'.$res['slug'].'/">'.$res['name'].'</a>';
else
$disp.='"><a href="?categoryID='.$res['categoryID'].'">'.$res['name'].'</a>';
$disp.=subcatt($res['categoryID']).'</li>';
}
}
$disp.='</ul>';
}
return $disp;
}}