View Full Version : How do I change the Rand function for news.php
Volconvo
04-17-2005, 05:16 AM
Hello,
I am aware that I can change ORDER BY in news.psp to ORDER BY RAND() LIMIT 1");
BUT...
how can I make it randomly show topics from after a certain date or only within the last 30 days..etc
In other words I do not want it showing topics that are super old.
Volconvo
04-17-2005, 06:40 PM
Anyone? :( I just want to put date limits on the Rand() function
Brian
04-17-2005, 06:50 PM
Change this:
WHERE forumid IN($vba_options[portal_news_forumid])
To this:
WHERE forumid IN($vba_options[portal_news_forumid]) AND postdateline > " . (TIMENOW - 2592000) . "
And that should limit it to show only posts made in the last 30 days.
Volconvo
04-17-2005, 08:17 PM
Hmm got an error page for that one:
Database error in vBulletin 3.0.3:
Invalid SQL:
SELECT
thread.threadid, thread.title, replycount, postusername, postuserid, thread.dateline AS postdateline, thread.lastposter, thread.lastpost, IF(views<=replycount, replycount+1, views) AS views, forumid, post.postid, pagetext, allowsmilie
, NOT ISNULL(subscribethread.subscribethreadid) AS subscribed
FROM thread AS thread
LEFT JOIN post AS post ON (post.postid = thread.firstpostid)
LEFT JOIN subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = '1')
LEFT JOIN deletionlog AS deletionlog ON (thread.threadid = deletionlog.primaryid AND type = 'thread')
WHERE forumid IN(7,8,11,10) AND postdateline > 1111187675 AND thread.visible = 1 AND thread.open != 10 AND deletionlog.primaryid IS NULL
GROUP BY post.postid
ORDER BY postdateline DESC
LIMIT 1
mysql error: Unknown column 'postdateline' in 'where clause'
mysql error number: 1054
Any idea?
seangworld
04-17-2005, 08:27 PM
i know you can pull random news from all of your forums by putting RAND in the appropriate box via your admincp>vba cmps...
but as far as only wanting to post news from the last 30 days or more recent, isn't that automatic anyway? i mean, your vba is only going to show the LATEST threads and LATEST news anyway. so, it seems to me a special code for what you want would be kinda useless. ;)
seangworld
04-17-2005, 08:30 PM
also, if you dont want to show topics that are super old, go back to your admincp>vb options and set it accordingly, and it'll affect your forum completely, as well as your vba. or, you can just go to your own usercp and set your own options so that YOU don't see super old topics, but your members can.
Brian
04-17-2005, 09:08 PM
Sorry about that. Try changing 'postdateline' in that code to 'thread.dateline' and that should take care of the problem.
Volconvo
04-17-2005, 10:46 PM
Brian..it displays correctly now, so thanks for that..but it did not do anything as far as random goes. It looks like it did before.
Brian
04-18-2005, 12:07 AM
It doesn't look like you changed the ORDER BY clause in the query.
Volconvo
04-18-2005, 01:50 AM
It doesn't look like you changed the ORDER BY clause in the query.
I actually changed it back since it did not do anything, but I will edit it again so you can see.
Volconvo
04-19-2005, 12:24 PM
bump...any idea guys :(
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.