1
munky2020
Alphabetize News when displayed. Will send $10 paypal for a solution
  • 2009/1/10 1:49

  • munky2020

  • Just popping in

  • Posts: 16

  • Since: 2008/11/25


I would like to alphabetize my news listings by article title when they come up under their topic in the news module. I have created a coupon website at http://desotonow.com u can login with login: demo pass:demo and would like to have the coupons alphabetized like the categories are under the topics directory. Help would be appreciated.

2
ghia
Re: Alphabetize News when displayed
  • 2009/1/10 9:24

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Did you check out the 'News Display Layout' in the preferences of the News module?
Your category of restaurants seems in order.

3
allenok
Re: Alphabetize News when displayed
  • 2009/1/10 23:41

  • allenok

  • Just popping in

  • Posts: 1

  • Since: 2009/1/10


I like your coupon website. could you tell me Which Module do you use for your coupon website? thanks

4
munky2020
Re: Alphabetize News when displayed
  • 2009/1/11 0:02

  • munky2020

  • Just popping in

  • Posts: 16

  • Since: 2008/11/25


under news display layout it displays either by date published or grouped by topic. but i want it to show up alphabetized by story title under each topic. i will paypal someone $10 if they have a solution to this

5
trabis
Re: Alphabetize News when displayed
  • 2009/1/11 12:38

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Open news/class/class.newsstory.php and around line 171 replace by this function:
/**
      * Returns published stories according to some options
      */
    
function getAllPublished($limit=0$start=0$checkRight=false$topic=0$ihome=0$asobject=true$order 'published'$topic_frontpage=false)
    {
        
$db =& Database::getInstance();
        
$myts =& MyTextSanitizer::getInstance();
        
$ret = array();
        
$sql 'SELECT s.*, t.* FROM '.$db->prefix('stories').' s, '$db->prefix('topics').' t WHERE (s.published > 0 AND s.published <= '.time().') AND (s.expired = 0 OR s.expired > '.time().') AND (s.topicid=t.topic_id) ';
        if (
$topic != 0) {
            if (!
is_array($topic)) {
                if(
$checkRight) {
                    
$topics news_MygetItemIds('news_view');
                    if(!
in_array ($topic,$topics)) {
                        return 
null;
                    } else {
                        
$sql .= ' AND s.topicid='.intval($topic).' AND (s.ihome=1 OR s.ihome=0)';
                    }
                } else {
                    
$sql .= ' AND s.topicid='.intval($topic).' AND (s.ihome=1 OR s.ihome=0)';
                }
            } else {
                if(
$checkRight) {
                    
$topics news_MygetItemIds('news_view');
                    
$topic array_intersect($topic,$topics);
                }
                if(
count($topic)>0) {
                    
$sql .= ' AND s.topicid IN ('.implode(','$topic).')';
                } else {
                    return 
null;
                }
            }
        } else {
            if(
$checkRight) {
                
$topics news_MygetItemIds('news_view');
                if(
count($topics)>0) {
                    
$topics implode(','$topics);
                    
$sql .= ' AND s.topicid IN ('.$topics.')';
                } else {
                    return 
null;
                }
            }
            if (
intval($ihome) == 0) {
                
$sql .= ' AND s.ihome=0';
            }
        }
        if(
$topic_frontpage) {
            
$sql .=' AND t.topic_frontpage=1';
        }

        
$sort 'DESC';
        if (
$order == 'title') {
            
$sort 'ASC';
        }
        
         
$sql .= " ORDER BY s.$order $sort";
        
$result $db->query($sql,intval($limit),intval($start));

        while ( 
$myrow $db->fetchArray($result) ) {
            if (
$asobject) {
                
$ret[] = new NewsStory($myrow);
            } else {
                
$ret[$myrow['storyid']] = $myts->htmlSpecialChars($myrow['title']);
            }
        }
        return 
$ret;
    }


Then open news/index.php

and replace around line 181 by this one
$sarray NewsStory::getAllPublished($xoopsOption['storynum'], $start$xoopsModuleConfig['restrictindex'], $xoopsOption['storytopic'], 0true'title'$topic_frontpage);


and replace around line 247 by this one:
$allstories NewsStory::getAllPublished($xoopsModuleConfig['storyhome'], 0$xoopsModuleConfig['restrictindex'], $topicid0true 'title');


I'll be glad if I receive my first donation ever
Link is on xuups.com

Login

Who's Online

176 user(s) are online (100 user(s) are browsing Support Forums)


Members: 0


Guests: 176


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits