Lof K2Scroller模块

时间:2012-03-28 07:16:55

标签: joomla joomla-extensions joomla-k2

我一直在使用Land of Coder开发的K2 Scroller模块。当我使用此模块在项目视图中显示相同的类别项目时,模块按创建日期的升序显示项目,这是后端模块参数设置中可用的默认设置。但是,我希望模块以日期降序显示项目。所以我选择编辑帮助程序中的默认代码,我想这是用于根据后端设置处理项目。这是帮助文件中代码的一部分,我认为它控制顺序:

public function __getList( $params ){
            global $mainframe;

                         /*some irrelevant code removed*/

                        $condition     = $this->buildConditionQuery( $params );
            $limitDescriptionBy = $params->get('limit_description_by','char');
            $ordering      = $params->get( 'k2_ordering', 'created_desc'); 
            $limit         = $params->get( 'limit_items',  5 );
            $ordering      = str_replace( '_', '  ', $ordering );
            $my            = &JFactory::getUser();
            $aid           = $my->get( 'aid', 0 );

                        /*some irrelevant code removed*/

            $extraURL       = $params->get('open_target')!='modalbox'?'':'&tmpl=component'; 
            $excludeIds     = $params->get('exclude_ids', '');
            $db     = &JFactory::getDBO();
            $date   =& JFactory::getDate();
            $now    = $date->toMySQL();
            $dateFormat = $params->get('date_format', 'DATE_FORMAT_LC3');

            $limitDescriptionBy = $params->get('limit_description_by','char');
            $isAuthor= $params->get('itemAuthor',0);
            require_once ( JPath::clean(JPATH_SITE.'/components/com_k2/helpers/route.php') );
            $query = "SELECT a.*, cr.rating_sum/cr.rating_count as rating, c.name as categoryname,
                            c.id as categoryid, c.alias as categoryalias, c.params as categoryparams, cc.commentcount as commentcount".
                    " FROM #__k2_items as a".
                        " LEFT JOIN #__k2_categories c ON c.id = a.catid" .
                        " LEFT JOIN #__k2_rating as cr ON a.id = cr.itemid".
                        " LEFT JOIN (select cm.itemid  as id, count(cm.id) as commentcount from #__k2_comments as cm
                                                                    where cm.published=1 group by cm.itemid) as cc on a.id = cc.id";

            $query .= " WHERE a.published = 1"
                        . " AND a.access get('featured_items_show','0') == 0 ){
                $query.= " AND a.featured != 1";
            } elseif(  $params->get('featured_items_show','0') == 2 ) {
                $query.= " AND a.featured = 1";
            }
            if( trim($excludeIds) ){
                $query .= " AND a.id NOT IN(".$excludeIds.") ";
            }
            $query .=  $condition . ' ORDER BY ' . $ordering;   
            $query .=  $limit ? ' LIMIT ' . $limit : '';

            $db->setQuery($query);
            $data = $db->loadObjectlist();

            /*some irrelevant code removed*/

                        return $data;   
        }


        /**
         * build condition query base parameter  
         * 
         * @param JParameter $params;
         * @return string.
         */
        public  function buildConditionQuery( $params ){
            $source = trim($params->get( 'k2_source', 'k2_category' ) );
            if( $source == 'k2_category' ){
                $catids = $params->get( 'k2_category','');

                if( !$catids ){
                    return '';
                }
                $catids = !is_array($catids) ? $catids : '"'.implode('","',$catids).'"';
                $condition = ' AND  a.catid IN( '.$catids.' )';
            } else {
                $ids = preg_split('/,/',$params->get( 'k2_items_ids',''));  
                $tmp = array();
                foreach( $ids as $id ){
                    $tmp[] = (int) trim($id);
                }
                $condition = " AND a.id IN('". implode( "','", $tmp ) ."')";
            }
            return $condition;
        }

我是否正在编辑代码的正确部分,或者我错过了其他内容。

我期待着你的帮助

感谢。

1 个答案:

答案 0 :(得分:0)

也许最好的方法是修改模块的xml文件。

我查看了Lof K2Scroller的代码(对于Joomla 2.5来说是v 2.2),并且有不同的订购选项。

但是,如果你想修改默认选项,你就在正确的文件中,只需将'created_desc'替换为'created_asc'。