Support jOOmla! Autoit!
单元页面罗列出所有分类的最新10个条目 输出PDF 打印 E-mail
Author Author: Autoit | Date Date:2007-04-11 | View Count View: 18840 | Digg Count Digg: 83

默认只显示 标题, 条目数及描述. 其实本站很早就改了.... 象最新文章模块一样的效果...

今天抽时间整理出来死送给论坛里急要的朋友:

 

方法: /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&amp;task=category&amp;sectionid='. $id .'&amp;id='. $row->id .'&amp;Itemid='. $Itemid );
      ?>
      <a href="<?php echo $link; ?>" class="category">
       <?php echo $row->name;?></a>
      <?php
      if ( $params->get( 'cat_items' ) ) {
       ?>
       &nbsp;<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&amp;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&amp;task=category&amp;sectionid='. $id .'&amp;id='. $row->id .'&amp;Itemid='. $Itemid );
      ?>
      <h3><a href="<?php echo $link; ?>"><?php echo $row->name;?>
      <?php if ( $params->get( 'cat_items' ) ) { ?>&nbsp;<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&amp;task=register' ); ?>">
       ( <?php echo _E_REGISTERED; ?> )</a>
      <?php
     }
    echo "</ul>";
   }
  }
 }

这样的话, 效果就是: 标题,条目数, 描述,最新10条, .... 下一单元重复...

要改 10 条为其他的话, 改上面的  a.created DESC LIMIT 10"; 里的 10 就可以了.

效果图就帖论坛了.....

end. 吃饭去...


Permanent URL: http://www.autoit.cn/index.php/content/view/107/25.html

Shares: Google书签 Yahoo书签 雅虎收藏夹 365Key网摘 新浪ViVi 百度收藏 天极网摘 diglog 和讯网摘 POCO网摘 YouNote网摘 博拉网 天下图摘 spurl blogmarks BlinkList reddit digg Del.icio.us   |  Tags: 单元  hack  

 
文章内增加网摘按钮   joomla 1.0.12 问题集