TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,985
  • Total Topics: 21,321
  • Online today: 4,016
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 389
  • Total: 389

Article Category Block Sorting

Started by othersi, December 20, 2006, 09:45:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

othersi

Hi all.

I've got an article system set up for our forum, with 3 categories... a category block for each one showing a half dozen articles inside.

Problem is, inside the article category blocks, the articles are sorted from oldest to newest (newest articles at the bottom of the list).

So... once the number of articles is greater than the number set for scroll bars in the blocks, the new articles don't show in the list... they are "off-screen" at the bottom of the block.

When I actually browse the categories, the articles are sorted newest to oldest.

Is there a way to alter the sorting inside the article block, so that they also sort newest to oldest?

JPDeni

#1
You would need to alter the file Sources/TPortal.php

Look for


    // any cat listings from blocks?
    if(isset($using_catlisting) && $fetchtitles!=''){
$request = db_query("SELECT art.id, art.subject, art.category, art.authorID, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE
$fetchtitles
AND art.off=0
AND art.approved=1
AND art.authorID=mem.ID_MEMBER", __FILE__, __LINE__);
         $context['TPortal']['blockarticle_titles']=array();


Change it to


    // any cat listings from blocks?
    if(isset($using_catlisting) && $fetchtitles!=''){
$request = db_query("SELECT art.id, art.subject, art.category, art.authorID, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE
$fetchtitles
AND art.off=0
AND art.approved=1
AND art.authorID=mem.ID_MEMBER
        ORDER BY art.date DESC", __FILE__, __LINE__);
         $context['TPortal']['blockarticle_titles']=array();


It's just adding the "ORDER BY" line.

This will likely affect other listings of articles as well.

othersi


This website is proudly hosted on Crocweb Cloud Website Hosting.