Category Ul-Li Tree structure For Menu Items
function category_navigation($pid,$level)
{
global $res;
global $catUlList;
$res[0] = "-Root-";
$blank = "";
for($i=0; $i< $level; $i++)
$blank .= "\t";
$parents = $this->find('all' , array('conditions' => array('Category.parent_id' => $pid)));
if(!empty($parents))
{
$catUlList .= "\n$blank
- ";
- ";
$catUlList .= "";
$catUlList .= $catName;
$catUlList .= "";
//$catUlList .= $html->link($catName, SITE_URL."products/".$value['Category']['id'].":".$catUrlName);
$this->category_navigation($value['Category']['id'],$level);
$catUlList .= "\n$blank ";
}
$level++;
foreach($parents as $value)
{
unset($value['ParentCategory']);
unset($value['Product']);
$catName = $value['Category']['name'];
$catUrlName = str_replace(" ","_",$value['Category']['name']);
$catUlList .= "\n$blank
}
if(!empty($parents))
{
$catUlList .= "\n$blank
}
$fp = fopen("category_ul_list.php","w");
fwrite($fp,$catUlList);
return $catUlList;
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home