7.5版本的正确操作:
function user_linknav($classid){ global $empire,$dbtbpre,$navclassid,$class_r,$public_r; //当前栏目 if($classid=="selfinfo"){ if(empty($navclassid)){ $classid=0; }else{ $classid=$navclassid; //终极类别则显示同级类别 if($class_r[$classid][islast]&&$class_r[$classid][bclassid]){ $classid=$class_r[$classid][bclassid]; } if($class_r[$classid][islast]&&empty($class_r[$classid][bclassid])){ $classid=0; } } } $query="select classname,bclassid,classpath,classurl from {$dbtbpre}enewsclass where classid=".$classid;
$sql=$empire->query($query); echo "<li><a href = \"/\">首页</a></li>"; while($r=$empire->fetch($sql)){ findparent($r[bclassid]); if($r[classurl]<>""){ echo "<li><a href =\"".$r[classurl]."\">".$r[classname]."</a></li>"; }else{ echo "<li><a href =\"/".$r[classpath]."\">".$r[classname]."</a></li>"; } } } //当前位置导航,递归查询父栏目 function findparent($classid){ global $empire,$dbtbpre; $query="select classname,bclassid,classpath,classurl from {$dbtbpre}enewsclass where classid=".$classid; $sql=$empire->query($query); while($r=$empire->fetch($sql)){ findparent($r[bclassid]); //如果是顶级栏目了,则前面不加“ > ”,否则再加 //$prefix=""; //if($r[bclassid]){$prefix = " > ";} //echo $prefix."<li><a href =\"/".$r[classurl]."\">".$r[classname]."</a></li>"; if($r[classurl]<>""){ echo "<li><a href =\"".$r[classurl]."\">".$r[classname]."</a></li>"; }else{ echo "<li><a href =\"/".$r[classpath]."\">".$r[classname]."</a></li>"; } } }
|