Hi
I just made some simple changes to three files within rquotes so it now has support for sequential display of quotes within a category.
I really would like to see next version having support for this.
So I just post it here to make it ultra simple for the author of rquotes to implement it, or eventually users of rquotes to make these quick changes themselves.
After the changes, and if you are using the rquotes module, then you can make rquotes order the display of the quotes using the field: "Daily Order", by setting the "Rotate_quotes(s)" (in the module) to "Sequential".
To work the client must have enabled cookies in his browser.
If he has not then it will display the quotes randomly.
How to implement for old users of rquotes (and for the author if he wants):
For it to work you need to change 3 files in this Joomla directory:
/modules/mod_rquotes/
*******************
1. file: helper.php
******************
After this function: getRandomRquote
Add this function:
Code
function getSequentialRquote($category){
// by PD, not yet implemented
// make use of cookie to store last displayed rquote
// if cookies not enabled then fetch randomly
$db =& JFactory::getDBO();
$query = "select #__rquotes_categories.name, #__rquotes.*
from #__rquotes_categories
inner join #__rquotes on (#__rquotes.category=#__rquotes_categories.name and #__rquotes.published='1')
WHERE #__rquotes_categories.id='$category'
order by #__rquotes.catid";
$db->setQuery( $query );
$rows = $db->loadObjectList();
$numRows = count($rows) - 1;
if (isset($_COOKIE['rquote'])){
$i = intval($_COOKIE['rquote']);
if ($i < $numRows)
$i++;
else
$i = 0;
setcookie('rquote',"$i");
$row = array( $rows[$i] );
} else {
// pick a random value
$i = rand(0, $numRows);
setcookie('rquote',"$i");
$row = array( $rows[$i] );
}
return $row;
}
elseif($rotate=='daily')
{
$list= getDailyRquote($category);
}
elseif($rotate=='sequential')
{
$list = modRquotesHelper::getSequentialRquote($category);
}
<param name="rotate" ....>
<option value ="daily">Daily</option>
<option value ="page_load">Every page load</option>
</param>
<option value ="sequential">Sequential</option>
User is Offline
Thank you very much for the Sequential code. I will issue a new version including it as soon as I can get it to work. I have made the changes but it's not working yet. I just get a blank page. I'll go over it again and see what happens.
Thanks again
User is Offlineundefined
Nice to hear that you liked it.
Hope you can include the fix for the published field as well in same version.
And would be cool if you could post here when the new version is published so I can
get it.
One more thing.
I'm sure you noticed that I only used one query in the function i wrote.
You can improve other queries in your code as well...
In this function: getRandomRquote
You use two queries... they can be merged into one by using inner join...
better to have fewer db calls.
There might be other places as well, but I do not have time to look through them... just happened to use getRandomRquote as basis for my function.
Last thing.
I see that in many of your functions e.g. this function: getRandomRquote
you use this two times:
$db =& JFactory::getDBO();
I do not understand why.... one should be enough...
calling it more will only use more cpu than needed.
Anyway, if do not get it to work ... please tell me...
Regards
User is OfflineWhen the soup has a leek in it
Limp Bizkit
Mark Twain [1835-1910]
Fred Allen