Joomla模块学习之后台mod

    技术2022-05-20  46

    Joomla模块学习之后台mod_popular模块

    热门文章模块

    后台管理模块效果图

     

    原理:

    后台mod_popular模块通过在后台配置相应的信息. 返回热门文章 

     

    配置界面:

     

     

    mod_popular模块结构图:

     

     

    关键代码

    (mod_popular.php代码) $db =& JFactory::getDBO(); //根据点击率排序,返回最热门的10篇文章 $query = 'SELECT a.hits, a.id, a.sectionid, a.title, a.created, u.name' . ' FROM #__content AS a' . ' LEFT JOIN #__users AS u ON u.id=a.created_by' . ' WHERE a.state <> -2' . ' ORDER BY hits DESC' ; $db->setQuery( $query, 0, 10 ); $rows = $db->loadObjectList(); ?> <table class="adminlist"> <tr> <td class="title"> <strong><?php echo JText::_( 'Most Popular Items' ); ?></strong> </td> <td class="title"> <strong><?php echo JText::_( 'Created' ); ?></strong> </td> <td class="title"> <strong><?php echo JText::_( 'Hits' ); ?></strong> </td> </tr> <?php foreach ($rows as $row) { $link = 'index.php?option=com_content&task=edit&id='. $row->id; ?> <tr> <td> <a href="<?php echo $link; ?>"> <?php echo htmlspecialchars($row->title, ENT_QUOTES, 'UTF-8');?></a> </td> <td> <?php echo JHTML::_('date', $row->created, '%Y-%m-%d %H:%M:%S'); ?> </td> <td> <?php echo $row->hits;?> </td> </tr> <?php } ?> </table>


    最新回复(0)