Jump to content

experienced php help needed


pauly_43

Recommended Posts

hello all,

I am a very novice php guy. just beginning out. i am trying to debug some code here that i didnt write. i just would like an experienced php guy to look it over and see any discrepancies or problems. the problem is that this menu tree that is being built cannot have a subsubmenu on the second to last sub menu item. the menu is breaking and re-ordering itself at that point.

here is the code...

------------------------

[code=php:0]
if(!isset($config)){
echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
exit;
}

$resultsForeign = $db->select("SELECT cat_master_id as cat_id, cat_name FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '".$lang_folder."'");
$box_content=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/boxes/categories.tpl");
$box_content->assign("LANG_CATEGORY_TITLE",$lang['front']['boxes']['shop_by_cat']);
$box_content->assign("LANG_HOME",$lang['front']['boxes']['homepage']);

DHTMLTree ($box_content,0);

function DHTMLTree (&$box_template,$cat_father_id) {
/*
Written by Alon Kobets.
http://www.natalie-shop.com

Based on Milos The conVict's Categories tree mod.
*/
global $db, $resultsForeign, $data, $c;

$results = $db->select("SELECT cat_name, cat_id FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = $cat_father_id ORDER BY cat_name ASC");
if($results == TRUE){
        for ($i=0; $i<count($results); $i++){

if(is_array($resultsForeign)){

for ($k=0; $k<count($resultsForeign); $k++){

if($resultsForeign[$k]['cat_id'] == $results[$i]['cat_id']){

$results[$i]['cat_name'] = validHTML($resultsForeign[$k]['cat_name']);

}

}

}

if (($cat_father_id > '0') && ($c < $cat_father_id)) {
$data .= "<ul>\n";
}
if (($cat_father_id < $c) && ($c > '0')) {
$data .= "</ul></li>\n";
}
$line = '<li><span></span><a href="index.php?act=viewCat&amp;catId='.$results[$i]['cat_id'].'">'.$results[$i]['cat_name'].'</a>';
$data .= $line."\n";
$box_template->assign("DATA",$data);
$c = $cat_father_id;
DHTMLTree($box_template,$results[$i]['cat_id'],$cat_father_id);
if ($c == $cat_father_id) {
$data .= "</li>";
}
      }
    }
}

$box_content->parse("categories");
$box_content = $box_content->text("categories");
?>
[/code]

-----------------------
-----------------------

the idea is this:

MAIN MENU:
------------

> SUB MENU >> sub sub menu (works)
> SUB MENU >> sub sub menu (works)
> SUB MENU >> sub sub menu (breaks)

I would really appreciate any help with this. ideas or anything at all.

thanks to all in advance.

paul_43

Link to comment
https://forums.phpfreaks.com/topic/30186-experienced-php-help-needed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.