TinyPortal

Development => Support => Topic started by: misjka on July 20, 2007, 07:17:01 AM

Title: Sorting order of articles in article blocks in frontpage?
Post by: misjka on July 20, 2007, 07:17:01 AM
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?
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bigdog on March 19, 2008, 05:17:40 PM
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.
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bloc on March 19, 2008, 11:59:23 PM
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.
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bloc on March 20, 2008, 12:15:29 AM
*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.

Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: misjka on March 20, 2008, 07:48:49 AM
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?
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bloc on March 20, 2008, 08:49:38 AM
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__);
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: misjka on March 20, 2008, 09:22:18 AM
Ah, many thanks  :up: and sorry about any confusion  :'(
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bigdog on March 20, 2008, 04:20:13 PM
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.
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bloc on March 20, 2008, 08:07:24 PM
I'll see f that can be a choice for TP 1.0. Sort of enhanced listing.
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bigdog on March 20, 2008, 09:38:03 PM
I would also suggest, bloc, that you add user permissions to be able to view articles, like you do for blocks.
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: misjka on March 20, 2008, 09:50:43 PM
yep, that goes for me too... and I guess plenty of others as well  >:D. But for now, I'm very pleased :).
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: IchBin on March 20, 2008, 10:27:50 PM
Category permissions are already there in TP 1.0. I don't see a point in doing a per article permission.
Title: Re: Sorting order of articles in article blocks in frontpage?
Post by: bigdog on March 21, 2008, 05:02:25 AM
Quote from: IchBinâ,,¢ on March 20, 2008, 10:27:50 PM
Category permissions are already there in TP 1.0. I don't see a point in doing a per article permission.
If I had 1.0, I wouldn't make the suggestion.  But if it category permissions are in place, article permissions would be nice to have as well.