View Full Version : Ideas needed on how this ordering can be achieved
Would like to showcase the following on the main links page.
Latest links
Most popular links
Random link
Each of these would be a block on the main page.
They would probably require 3 different queries.
My question is how can I achieve this :
I can set in the Admincp option : display orders for each block, such that I can arrange which block appears first, second and third.
Any ideas would be most appreciated :D
Thanks
trafix
02-17-2005, 09:25 AM
look at the coding for the jukebox .... it has most of that for playing defult song ;)
I did a quick scan, I presume you mean the part below
//start load the song
of the vb_jukebox.php file ?
Don't really think it does what I seek ?
trafix
02-17-2005, 09:44 AM
Most popular links
this finds the most played song
$mostplayed = $DB_site->query_first("
SELECT *
FROM " . TABLE_PREFIX . "vb_jukebox_trax
WHERE active = 1
ORDER BY plays
DESC LIMIT 1
");
Random link
$getimage = $DB_site->query_first("
SELECT *
FROM " . TABLE_PREFIX . "vb_jukebox_trax
WHERE active = 1
ORDER BY RAND() DESC LIMIT 1
");
I know the query to get the stuff i need :p
What i mean is how could I order the blocks that shows these stuff ( latest, random, most popular ) based on changeable settings for display orders in the Admincp. :)
edit: p.s I think order by rand() desc makes no sense :) just order by rand() will do.
sabret00the
02-17-2005, 09:54 AM
seriously i'd just suggest adding a column to the table "block_order" and then ORDER BY links.block_order
Hmm, isn't there another means ?
Dean C
02-17-2005, 12:26 PM
I wouldn't use queries for this. Use vBcron and cache the info every x hours :)
You lost me there, Dean :)
sabret00the
02-17-2005, 02:42 PM
the only other way i can think of cinq is to do something like set it up in the vboptions so you can have the blocks orders then in your code set em out as an array, then cycle through the array with a while, using the block id's to set the order
i.e.
vboptions[blockorder1]
vboptions[blockorder2]
vboptions[blockorder3]
ok this may be impossible without a query but use a function to arrange them in numerical order as an array
numorder[array] //would look something like = "3, 1, 2"
ofcourse for that you'd need to assume your instructions dictate that which block is which number in the array
anyway from there
while($order = $numorder[array])
{
$block .= "$order[blockid]";
}
i can't explain it but chances are if i wanted to do what you're trying that'd be what i'd try.
Thanks for trying to explain it sabe but I still don't quite get it :(
I'm still drawing a blank at how I should do this :(
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.