mytidbits.us

  • Increase font size
  • Default font size
  • Decrease font size
Message
  • You don't have permission to view member list. Please login or register!
Home Rquotes Forum
MyTidBits Forum
Board Index
>
General Rquotes Questions
Sequential hack - and feature request
Welcome, Guest

Sequential hack - and feature request
Post Sequential hack - and feature request
by bongobongo on Dec, 19.2009 10:26

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;
}
 



***********************
2. file: mod_rquotes.php
**********************

after this block of code:

Code
 
elseif($rotate=='daily')
{
$list= getDailyRquote($category);
}
 


add this code:
Code
 
elseif($rotate=='sequential')
{
$list = modRquotesHelper::getSequentialRquote($category);
}
 


**********************
3. file: mod_rquotes.xml
**********************

find this parameter:
Code
 
<param name="rotate" ....>
<option value ="daily">Daily</option>
<option value ="page_load">Every page load</option>
</param>
 


Now add this third option after the last option in code above:
Code
 
<option value ="sequential">Sequential</option>
 



**************
DONE...
Time to test (remember to add a unique number in this field "Daily Order" for each quote within a category)
**************

Happy quoting!

Regards


bongobongo

bongobongo

Joo!BB - Newie
Joo!BB - Newie
Registered

Posts: 6

Joined Board
Dec, 15.2009 09:49
Last Visit
Jul, 09.2010 04:28
Offline User is Offline

View all users posts


re: sequentail hack
Post re: sequentail hack
by admin on Dec, 20.2009 11:54

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


admin

admin

Joo!BB - Hero
Joo!BB - Hero
Administrator

Posts: 118

Joined Board
Oct, 01.2008 02:07
Last Visit
Jul, 31.2010 10:49
Offline User is Offline

View all users posts

undefined


Re: Sequential hack - and feature request
Post Re: Sequential hack - and feature request
by bongobongo on Dec, 20.2009 17:08

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


bongobongo

bongobongo

Joo!BB - Newie
Joo!BB - Newie
Registered

Posts: 6

Joined Board
Dec, 15.2009 09:49
Last Visit
Jul, 09.2010 04:28
Offline User is Offline

View all users posts


MyTidBits Forum

How you want to use Rquotes component

Rquotes component
 

Daily-Tidbit

Once you're in heaven, do you get stuck wearing the clothes you were buried in for eternity?


How you want to use Rquotes module

Rrquotes Module
 

DB Sequential Quotes

" When is it OK to eat vegetable soup in a cracked bowl? "

When the soup has a leek in it


Welcome to www.mytidbits.us You are connected from 38.107.191.111 Have a great day!!

Random From Text File

"I can't really remember the names of the clubs that we went to."-- Shaquille O'Neal on whether he had visited the Parthenon during his visit to Greece

Daily from Text File

This line will be displayed on the 1st day of every mounth.

Forum Posts

on this day

by admin
on Jul, 31.2010 10:54

DB-Multy Random

" You make believe that nothing is wrong until you're cryin'
You make believe life is so long until you're dyin'......
"

Limp Bizkit


" The only way to keep your health is to eat what you don't want,
drink what you don't like and do what you'd rather not.
"

Mark Twain [1835-1910]


DB Daily Quote

Quote5. This information will be displayed all day.


DB Single Random

" A meeting is a gathering of important people who singly can do nothing, but together can decide that nothing can be done. "

Fred Allen