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

Message
  • You have no permission to edit this post
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: 8

Joined Board
Dec, 15.2009 09:49
Last Visit
Aug, 07.2010 16:16
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: 122

Joined Board
Oct, 01.2008 02:07
Last Visit
Sep, 06.2010 17:38
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: 8

Joined Board
Dec, 15.2009 09:49
Last Visit
Aug, 07.2010 16:16
Offline User is Offline

View all users posts


MyTidBits Forum

How you want to use Rquotes component

Rquotes component
 

Daily-Tidbit

Why do you have to 'put your two cents in'... but it's only a 'penny for your thoughts'?  Where's that extra penny going to?


How you want to use Rquotes module

Rrquotes Module
 

DB Sequential Quotes

" When is a river like the letter 'T'? "

When it must be crossed


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

Random From Text File

There are 3 kinds of people:Those who can count,and those who cannot.~George Carlin

Daily from Text File

This line will be displayed on the 7th day of every mounth.

Forum Posts

Re: Rotate questions

by Lukum
on Sep, 01.2010 06:26

DB-Multy Random

" And life is what we make it.
Always has been, always will be.
"

Grandma Moses


" I have always felt sorry for people afraid of feeling,
of sentimentality, who are unable to weep with their
whole heart. Because those who do not know how
to weep do not know how to laugh either.
"

Golda Meir


DB Daily Quote

Quote4. This information will be displayed all day.


DB Single Random

" That best portion of a good man's life--
His little, nameless, unremembered,
acts of kindness and of love.
"

William Wordsworth