默认只显示 标题, 条目数及描述. 其实本站很早就改了.... 象最新文章模块一样的效果...
今天抽时间整理出来死送给论坛里急要的朋友:
方法: /components/com_content/content.html.php [~137行开始, 搜 function showCategories 就可以了]
将此段..
/**
* Display links to categories
*/
function showCategories( &$params, &$items, $gid, &$other_categories, $catid, $id, $Itemid ) {
if(!count($other_categories)) return;
?>
<ul>
<?php
foreach ( $other_categories as $row ) {
$row->name = htmlspecialchars( stripslashes( ampReplace( $row->name ) ), ENT_QUOTES );
if ( $catid != $row->id ) {
?>
<li>
<?php
if ( $row->access <= $gid ) {
$link = sefRelToAbs( 'index.php?option=com_content&task=category&sectionid='. $id .'&id='. $row->id .'&Itemid='. $Itemid );
?>
<a href="<?php echo $link; ?>" class="category">
<?php echo $row->name;?></a>
<?php
if ( $params->get( 'cat_items' ) ) {
?>
<i>( <?php echo $row->numitems; echo _CHECKED_IN_ITEMS;?> )</i>
<?php
}
// Writes Category Description
if ( $params->get( 'cat_description' ) && $row->description ) {
?>
<br />
<?php
echo $row->description;
}
} else {
echo $row->name;
?>
<a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&task=register' ); ?>">
( <?php echo _E_REGISTERED; ?> )</a>
<?php
}
?>
</li>
<?php
}
}
?>
</ul>
<?php
}
替换为:
/**
* Display links to categories
*/
function showCategories( &$params, &$items, $gid, &$other_categories, $catid, $id, $Itemid ) {
global $database, $mainframe;
if(!count($other_categories)) return;
foreach ( $other_categories as $row ) {
$row->name = htmlspecialchars( stripslashes( ampReplace( $row->name ) ), ENT_QUOTES );
if ( $catid != $row->id ) {
if ( $row->access <= $gid ) {
$link = sefRelToAbs( 'index.php?option=com_content&task=category&sectionid='. $id .'&id='. $row->id .'&Itemid='. $Itemid );
?>
<h3><a href="<?php echo $link; ?>"><?php echo $row->name;?>
<?php if ( $params->get( 'cat_items' ) ) { ?> <i>( <?php echo $row->numitems; echo _CHECKED_IN_ITEMS;?> )</i>
<?php }
echo "</a></h3>";
// Writes Category Description
if ( $params->get( 'cat_description' ) && $row->description ) {
echo $row->description;
}
echo "<ul class=\"latestnews-grey\">";
$query1="SELECT a.id, a.title"
. "\n FROM #__content AS a"
. "\n WHERE catid='". $row->id ."'"
. "\n AND a.state = 1"
. "\n ORDER BY a.created DESC LIMIT 10";
$database->setQuery( $query1 );
$rows = $database->loadObjectList();
$bs = $mainframe->getBlogSectionCount();
$bc = $mainframe->getBlogCategoryCount();
$gbs = $mainframe->getGlobalBlogSectionCount();
foreach ( $rows as $row ) {
$Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs );
if ($Itemid == NULL) {
$Itemid = '';
} else {
$Itemid = '&Itemid='. $Itemid;
}
$link = sefRelToAbs( 'index.php?option=com_content&task=view&id='. $row->id . $Itemid );
?>
<li class="latestnews-grey"><a href="<?php echo $link; ?>" class="latestnews<?php echo $class_sfx; ?>"><?php echo $row->title; ?></a></li>
<?php }
} else {
echo $row->name;
?>
<a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&task=register' ); ?>">
( <?php echo _E_REGISTERED; ?> )</a>
<?php
}
echo "</ul>";
}
}
}这样的话, 效果就是: 标题,条目数, 描述,最新10条, .... 下一单元重复...
要改 10 条为其他的话, 改上面的 a.created DESC LIMIT 10"; 里的 10 就可以了.
效果图就帖论坛了.....
end. 吃饭去...