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,965
  • Latest: boruko
Stats
  • Total Posts: 195,982
  • Total Topics: 21,320
  • Online today: 431
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 92
  • Total: 92

Sorting order of articles in article blocks in frontpage?

Started by misjka, July 20, 2007, 07:17:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

misjka

Hi!

I have a site where I only use article blocks as frontpage blocks. But as I've found out, the sorting order of the articles within the blocks isn't alphabetically by subject NOR by publishing date...

So my question is: What is the publishing order of articles in article blocks? Is it by the primary keys in the SQL table or what?

Anyway, shouldn't that be changed to, at least, alphabetically by subject or by date?

bigdog

be nice if it was by date.

It would also be nice if it would sort by date, and allow for the display of the article introduction text/image.  This way, in a category display block, you could say show only the last 5 articles, with the most recent at the top, keeping a homepage/frontpage block constantly and automatically updated with your newest article content.

bloc

The article-box has been neglected to some point in these areas, and should yes, sort properly on critera. Preferably a adjustable one. I will address this better for TP 1.0.

In the meantime, you can change this easily. Open TPortal.php and find this code block:

    if(isset($using_article) && $fetchart!=''){
$request = db_query("SELECT art.*, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE
$fetchart
AND art.off=0
AND art.approved=1
AND art.authorID=mem.ID_MEMBER", __FILE__, __LINE__);


change to:

    if(isset($using_article) && $fetchart!=''){
$request = db_query("SELECT art.*, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE
$fetchart
AND art.off=0
AND art.approved=1
AND art.authorID=mem.ID_MEMBER ORDER BY art.date DESC", __FILE__, __LINE__);


Thats for sorting on date, newest first. For subject sorting use ORDER BY art.subject ASC.

bloc

*smacks head*

I totally forgot..this won't help much really, becasue its the blocks placement that decides what article comes first, as each articleblock specifies one particular article.

On that aspect it can't auto-sort, as the blocks use a position system.


misjka

Oh, sorry and oops Bloc  :o!

I don't use article blocks but article cateogory blocks.... Then perhaps your solution will help, on the other hand  :D?

bloc

ah, that explains it lol.

And yes, it does. To clear it up, here the code you need to look for in TPortal.php:

    // any cat listings from blocks?
    if(isset($using_catlisting) && $fetchtitles!=''){
$request = db_query("SELECT art.id, art.subject, art.category, art.authorID, art.shortname, 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__);


and what to replace it with:

    // any cat listings from blocks?
    if(isset($using_catlisting) && $fetchtitles!=''){
$request = db_query("SELECT art.id, art.subject, art.category, art.authorID, art.shortname, 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__);

misjka

Ah, many thanks  :up: and sorry about any confusion  :'(

bigdog

wonderful.  What about adding the intro text for the article in the category box?

We have that working on our homepage, using the recent articles code snippet stickied in your code forum.  It would be great to have a tp category block do this as well, since it's easier to manage within the tp admin panel.

bloc

I'll see f that can be a choice for TP 1.0. Sort of enhanced listing.

bigdog

I would also suggest, bloc, that you add user permissions to be able to view articles, like you do for blocks.

This website is proudly hosted on Crocweb Cloud Website Hosting.