Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums How To Sorting news
1 2
Chris
Posted on 15 Oct 2009, 19:24:45

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

You can sort the news by the date it was posted, the rating it has or the amount of views each post has. By default if you don't specify the $orderby variable the system will sort them by the date they were posted.

Code:
<?php
$orderby 
= 'rating'; #sort by ratings
$newsorder = 'ASC' #ascending order
include 'news/index.php';
?>


Code:
<?php
$orderby 
= 'views'; #sort by view count
$newsorder = 'DESC'; #descending order, also default
include 'news/index.php';
?>
#974
Last edited by Chris at 2009-12-26 15:11:49 Reason:
Dallas
Posted on 16 Oct 2009, 17:13:03

Access: Member
Total Posts: 10
Joined: 2009-09-14

By default if you don't specify the $orderby variable the system will sort them by the date they were posted.

But is there a way to show the news by the date they were posted?
Under "Toggle date" you can set a date to what you want, "timestamp" in Db
and I want to write news earlier than the news is publish.

Dallas
#988
Chris
Posted on 16 Oct 2009, 17:24:14

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

By default the system sorts the news by date, that is it sorts it by the timestamp. When posting your news you can use the toggle date function to change the date which will also change the timestamp which will in turn affect what order your news gets displayed in.
#989
Dallas
Posted on 16 Oct 2009, 18:19:41

Access: Member
Total Posts: 10
Joined: 2009-09-14

Hi

Yes I understand, but I want to "orderby" date <= "today"

if the "date-timestamp" is older or the same day as today, show the news

if the "date-timestamp" is in the future , don´t show the news

Dallas
(sorry for my english)
#990
Chris
Posted on 16 Oct 2009, 19:03:08

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

This is possible by making a small edit. Edit the index.php file, around line 549~ you'll see this line of code

Code:
$sql =  "SELECT title, story, shortstory, author, origauthor, ip, timestamp, allowcomments, short, approved, viewcount, rating, archivedate, neverarchive, archived, id, $newsusers.user, $newsusers.profile_image AS profileimage, $newsaccess.name AS accessname FROM $newstable LEFT JOIN $newsusers ON $newstable.author = $newsusers.uid LEFT JOIN $newsaccess ON $newsusers.access = $newsaccess.uid WHERE approved = '1' $f $u AND archived = '0' ORDER BY $orderby $newsorder LIMIT  $start, $amounttoshow";


replace that with this

Code:
$sql = "SELECT title, story, shortstory, author, origauthor, ip, timestamp, allowcomments, short, approved, viewcount, rating, archivedate, neverarchive, archived, id, $newsusers.user, $newsusers.profile_image AS profileimage, $newsaccess.name AS accessname FROM $newstable LEFT JOIN $newsusers ON $newstable.author = $newsusers.uid LEFT JOIN $newsaccess ON $newsusers.access = $newsaccess.uid WHERE approved = '1' $f $u AND archived = '0' AND timestamp <= '" . time() . "' ORDER BY $orderby $newsorder LIMIT  $start, $amounttoshow";


Now the system won't display any news posts that are 'in the future'
#991
Last edited by Chris at 2009-10-16 19:05:40 Reason:
Dallas
Posted on 16 Oct 2009, 19:36:01

Access: Member
Total Posts: 10
Joined: 2009-09-14

Thank you! :original:

Perfect... tested

Dallas
#992
Angel
Posted on 12 Feb 2010, 18:10:45

Access: Member
Total Posts: 9
Joined: 2010-02-01

It is possible to arrange for title(degree) (to a - z)

pardon for my Englishman
#1854
Chris
Posted on 12 Feb 2010, 18:15:11

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Currently it is not possible to sort by title from A-Z, but I'll add that to the to do list for version 3.5
#1855
Angel
Posted on 12 Feb 2010, 18:20:15

Access: Member
Total Posts: 9
Joined: 2010-02-01

Ok, thank you
#1856
Alankeys
Posted on 17 Jun 2010, 10:26:38

Access: Member
Total Posts: 107
Joined: 2009-11-28

Chris

Created 'most viewed news' and 'most comments' list easily, but is there a way to show 'most recent comments' ?


#2515
1 2
Network-13.com © 2013