Go Back   Pligg CMS Forum > Pligg Development > Pligg Modules > Module Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2008, 10:56 AM
New Pligger
 
Join Date: Feb 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Randomize RSS Import

Hello!

I have setup RSS Imports with many feeds. Now when I do an import, the last setup RSS import imports the last and the home page is filled with items of that particular feed.

Now am wondering if there is a way to randomize the imported items from all feeds??

Thanks
Envieme
Reply With Quote
  #2 (permalink)  
Old 06-17-2008, 12:25 PM
Casual Pligger
 
Join Date: Jan 2007
Posts: 38
Thanks: 4
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by envieme View Post
Hello!

I have setup RSS Imports with many feeds. Now when I do an import, the last setup RSS import imports the last and the home page is filled with items of that particular feed.

Now am wondering if there is a way to randomize the imported items from all feeds??

Thanks
Envieme
I agree! This would be excellent! :-)
Reply With Quote
  #3 (permalink)  
Old 06-17-2008, 04:27 PM
davemackey's Avatar
Pligg Donor
Pligg Version: 9.9.
Pligg Template: siChunkBlue
 
Join Date: Aug 2007
Location: Langhorne, PA
Posts: 286
Thanks: 33
Thanked 18 Times in 14 Posts
The easiest way to do this is by setting up a cron job. Lower the number of stories it imports from each feed (say to 1) and then set the cron job to run every x period. This will pull one story from each feed and then start the whole process over again the next time the feed pulls. This works well, the one problem I have is that I want it to run every five minutes or so, but RSS Importer currently allows a minimum of 1 hour between pulls...I'm still looking for the code to change for this.
David.
Reply With Quote
The Following User Says Thank You to davemackey For This Useful Post:
  #4 (permalink)  
Old 06-17-2008, 04:46 PM
chuckroast's Avatar
Coder/Designer
Pligg Version: 1.0
Pligg Template: ExpertVision
 
Join Date: Jun 2006
Location: PA
Posts: 2,399
Thanks: 171
Thanked 439 Times in 278 Posts
Quote:
Originally Posted by davemackey View Post
This works well, the one problem I have is that I want it to run every five minutes or so, but RSS Importer currently allows a minimum of 1 hour between pulls...I'm still looking for the code to change for this.
David.
Hey Dave check
modules/rss_import/templates/import_fields_center.tpl
look for

$y = (time() - ($feed->feed_freq_hours * 3600));

Hope that helps.
__________________
Visit PliggPro the official Pligg Mods & Template Shop!

Reply With Quote
The Following 2 Users Say Thank You to chuckroast For This Useful Post:
  #5 (permalink)  
Old 06-17-2008, 06:20 PM
Casual Pligger
 
Join Date: Jan 2007
Posts: 38
Thanks: 4
Thanked 0 Times in 0 Posts
Thank you for the nice tip!
Reply With Quote
  #6 (permalink)  
Old 06-18-2008, 01:07 AM
New Pligger
 
Join Date: Feb 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by chuckroast View Post
Hey Dave check
modules/rss_import/templates/import_fields_center.tpl
look for

$y = (time() - ($feed->feed_freq_hours * 3600));

Hope that helps.
Thanks for the idea.

But isn't there a way to make the import random? Like in import.php I have been trying to do but can't figure out how!
Reply With Quote
  #7 (permalink)  
Old 06-18-2008, 11:36 PM
davemackey's Avatar
Pligg Donor
Pligg Version: 9.9.
Pligg Template: siChunkBlue
 
Join Date: Aug 2007
Location: Langhorne, PA
Posts: 286
Thanks: 33
Thanked 18 Times in 14 Posts
Thanks chuckroast, I'll give that a try.
Reply With Quote
  #8 (permalink)  
Old 07-17-2008, 10:03 PM
davemackey's Avatar
Pligg Donor
Pligg Version: 9.9.
Pligg Template: siChunkBlue
 
Join Date: Aug 2007
Location: Langhorne, PA
Posts: 286
Thanks: 33
Thanked 18 Times in 14 Posts
Okay, figure I'd post what I've found out. The actual line of code I need is this one in import_fields_center.tpl:
PHP Code:
} elseif ( ( (time() - ($feed->feed_freq_hours 3600)) > strtotime($feed->feed_last_check) ) && ($_GET['override'] == '') ) { 
This is the second half of a If...Then statement and says what to do if the user is not attempting an override of the time feature. Let's break it down:
time() = a php function equal to the number of seconds since 1/1/1970.
$feed->feed_freq_hours = how frequently the feed should be grabbed.
*3600 = creates a value in seconds.
Thus for example, the first part with constants might look like
(1198368000 - (1 * 3600))
Which in turn reduces down to:
(1198364400)
Okay, now the second half:
strtotime($feed->feed_last_check) = Grabs the value and changes it into a time that the feed was last checked.
&& ($GET['override'}=='' = Says that this only occurs if there is no override of the time functionality.
We don't need to pay attention to most of it, just boil it down to:
1198364400 > last_check.
Let's say just for argument that the check was ten minutes before the current time:
1198364400 > 1198363800
Its not true. This is because we subtracted an hour from now to find our next check time but only ten minutes from the last check.
So, let's say I want to make it check every five minutes, I would do this:
(time() - ($feed->feed_freq_hours * 300))
300 = 60 * 5.
Thus we are only subtracting five minutes from the current time, allowing it to run every five minutes.
Thats all for now folks. Let me know if you have questions!
David.
Reply With Quote
  #9 (permalink)  
Old 07-17-2008, 10:42 PM
davemackey's Avatar
Pligg Donor
Pligg Version: 9.9.
Pligg Template: siChunkBlue
 
Join Date: Aug 2007
Location: Langhorne, PA
Posts: 286
Thanks: 33
Thanked 18 Times in 14 Posts
Well, that doesn't seem to be working. Can anyone see an issue in the code I'm missing?
David.
Reply With Quote
  #10 (permalink)  
Old 07-18-2008, 10:54 AM
New Pligger
Pligg Version: 9.9
Pligg Template: coolwater
 
Join Date: Feb 2007
Location: Atlanta, GA
Posts: 22
Thanks: 1
Thanked 5 Times in 5 Posts
Smile

You are actually multiplying 300*5 in your code giving you 1500 seconds or 25 minutes. I'd say the best way to do this so it is still configurable from the admin control panel is by changing the 3600 constant to 60 seconds (1 minute)

PHP Code:
//While $feed->feed_freq_hours reads hours,
//it would actually be referring to minutes in this case
} elseif ( ( (time() - ($feed->feed_freq_hours 60)) > strtotime($feed->feed_last_check) ) && ($_GET['override'] == '') ) { 
Once you've made that change you would just setup the time as you normally would for each feed in the control panel, just use minutes instead of hours for the time between imports.
I haven't tested this, but I'm pretty sure it should work.
__________________
Pligg Site: www.NewsHeat.com
Slogan: Where The Campaign Trails Meet
Pligg Version: beta v9.9 (updated since 9.1)
Template: Modified "coolwater"
Other Sites: Cheesy Movie Night, Tranquil Aggression
Reply With Quote
The Following User Says Thank You to NewsHeatDotCom For This Useful Post:
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture video thumbnails from rss import and display them on published/upcoming site tand Modification Tutorials 7 05-16-2008 03:16 AM
RSS import not working rssblog Modification Tutorials 0 03-05-2008 04:19 AM
RSS Importer: How can I import individual feeds, not all I have set up? slobizman General Help 1 01-03-2008 03:36 AM
Rss import = blank argh2xxx Bug Report 5 05-17-2007 11:26 PM
RSS import feature srrpenna General Help 4 12-28-2006 06:39 AM


Search Engine Friendly URLs by vBSEO 3.2.0