特此鸣谢简爱http://www.gouji.org/)提供的代码,下图为效果:

QQ拼音截图未命名.jpg

 

此效果为鼠标移到一级分类上展开显示二级分类,代码如下:

<?php
//widget:分类
function widget_sort($title){ global $CACHE; $sort_cache = $CACHE->readCache('sort'); ?>
  <div class="widget m-echo">
  <h3><?php echo $title; ?></h3>
  <ul id="blogsort">
  <?php // lognum description
  foreach($sort_cache as $value):
	if ($value['pid'] != 0) continue;
	$Children = ''; $LogNum = $value['lognum'];
	if (!empty($value['children'])) {
	  $Children .= '<i class="fa"></i><ul>';
	  foreach ($value['children'] as $sid) {
		if(isset($GLOBALS['ja_zt']['sort']) && $sort_cache[$sid]['sid'] == $GLOBALS['ja_zt']['sort'])
		  $class = "class=\"ja_sort\" ";
		else
		  $class = "";
		$Children .= '<li><a '. $class .'href="'. Url::sort($sort_cache[$sid]['sid']) .'" title="当前分类下文章 ['.$sort_cache[$sid]['lognum'].']&#10;'.$sort_cache[$sid]['description'].'">';
		$Children .= $sort_cache[$sid]['sortname'] .'('. $sort_cache[$sid]['lognum'] .')</a></li> ';
		$LogNum   += $sort_cache[$sid]['lognum'];
	  }
	  $Children .= '</ul>';
	}
	if(isset($GLOBALS['ja_zt']['sort']) && $value['sid'] == $GLOBALS['ja_zt']['sort'])
	  $class = "class=\"ja_sort\" ";
	else
	  $class = "";
  ?>
	  <li>
		<a <?php echo $class; ?>href="<?php echo Url::sort($value['sid']); ?>" title="当前分类下文章 [<?php echo $value['lognum']; ?>]&#10;<?php echo $value['description']; ?>"><?php echo $value['sortname']; ?>(<?php echo $LogNum ?>)</a> <?php echo $Children; ?>
	  </li>
  <?php endforeach; ?>
  </ul>
  <style>
#blogsort li:hover .sb {
	color: #F60
}

#blogsort ul li {
	line-height: 20px;
	padding: 0 0 5px 8px;
	margin-bottom: 0;
	border-bottom: 0
}

#blogsort li ul {
	display: none
}

#blogsort li:hover ul {
	display: block
}</style>
  </div>
<?php }?>