<?php 
if(arg(0) == 'category'){
	$term = get_term_bytid(arg(1));
	if($term->field_id == 1){
		$newstid = get_allterm_bytid($term->tid);
		if($term->weight != 0){
			$data = article_list(arg(1),0,10,1);
			if($data){foreach($data as $val){
				$con .= '<li><a href="'.$val->url.'">'.$val->title.'</a></li>';
			}}
		}else{
			$terms = get_sonterm_bytid(arg(1));
			if(count($terms) == 0){
				$terms = get_sonterm_bytid($term->pid);
			}
			if($terms){foreach($terms as $term){
				$con .= '<li><a href="'.$term->url.'">'.$term->name.'</a></li>';
			}}
		}
	}elseif($term->field_id == 2){
		$con = product_box();
		$class = 'product';
	}
	$class = arg(0);
}elseif(arg(0) == 'product'){
	$con = product_box();
	$term->name = '产品分类';
	$class = arg(0);
}elseif(arg(0) == 'article'){
	$article = article_load(arg(1));
	$term = get_term_bytid($article->fields['lanmu']->tid);
	if($term->field_id == 1){
		$newstid = get_allterm_bytid($term->tid);
		if($term->weight != 0){
			$data = article_list($term->tid,0,10,1);
			if($data){foreach($data as $val){
				$con .= '<li><a href="'.$val->url.'">'.$val->title.'</a></li>';
			}}
		}else{
			$terms = get_sonterm_bytid(arg(1));
			if(count($terms) == 0){
				$terms = get_sonterm_bytid($term->pid);
			}
			if($terms){foreach($terms as $term){
				$con .= '<li><a href="'.$term->url.'">'.$term->name.'</a></li>';
			}}
		}
	}elseif($term->field_id == 2){
		$con = product_box();
		$term->name = '产品分类';
		$class = 'product';
	}
	$class = arg(0);
}elseif(arg(0) == ''){
	$con = product_box();
	$term->name = '产品分类';
	$class = 'product';	
}
echo '<div class="block block_module_block '.$class.' category'.$term->tid.'">
      <h3 class="block_title">'.$term->name.'</h3>
    <div class="block_content"><ul>'.$con.'</ul></div>
</div>';

function product_box(){
	$terms = get_term_byvname('lanmu', 'product', 10);
	if(count($terms) == 0){
		$terms = get_sonterm_bytid($term->pid);
	}
	if($terms){foreach($terms as $term){
		$con .= '<li><a href="'.$term->url.'">'.$term->name.'</a></li>';
	}}

	return $con;
}
;?>