The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Creating a sheduled task from this code
Hello.
I have modified the code from this module to create a file i can use for an rss feed of the events calendar, i dont know php so its been a bit of reading and trial and error, theres probably a much better way to do this, but for now it seems to work. Problem is its done as a widget so it runs on every page load, which when the site gets bigger will get higher usage on the server. Kan i ask if anyone out there can show me how to convert the code below so it runs as a sheduled task from a cron file? Many thanks Carl PHP Code:
|
#2
|
|||
|
|||
I'm confused reading that code - it doesn't look like there would be any output in the widget, since it all gets written to the file.
In any case, an easy way to make it a scheduled task would be to create a plugin using hook location cron_script_cleanup_daily or cron_script_cleanup_hourly (but of course then you're limited to running it once per hour or day). |
#3
|
|||
|
|||
Many thanks, yes you are correct, theres no output, other than what it writes to a file, thus at the moment i can place the widget onto my pages using a stripped template, so theres no visible trace at all visible on my pages, each time the widget loads on the page the file / rss file is updated thus i can now go here :
http://www.bidefordmarket.co.uk/bide...teventlist.rss and see an rss feed just for the events. Heres where i am completely at a loss, i dont know php, i copied and pasted bits and tried things until they worked. I have a small concern regarding weird characters in the events posts, this seemed to break the rss page so it showed a "Page cannot be displayed" message, but on the whole seems to function ok.. Heres the thing i am laughing here i dont know php, not sure about hooks and things so you lost me The code above is contained in a widget and seems a variation, the code inside some of the cron files looks like real php if the code above works inside a widget, what do i need to do in order to create a new cron file say : events2rss.php , take the code above and place it in the new cron file and have it work? if i for example use a copy of the sitemap.php cron file and call it rssevents.php, strip it and paste the code above into it i get an error of : Fatal error: Call to a member function query_read() on a non-object in /home/b1d3f0rd/public_html/includes/cron/rssevents.php on line 36 the code i now have in my new cron/rssevents.php file are as follows: any advice is great Many thanks in advance.. Carl PHP Code:
|
#4
|
|||
|
|||
When you say "cron" you're setting it up as a scheduled task using the php file you created, right? (Sometimes people get confused between that and the actual operating system cron). Assuming you are, I'm not sure why you're getting that error because I thought that $db was always a global with the database object, but that error looks like it's saying that it's not. So you could try changing your code to use $vbulletin->db in place of $db (I see 4 places where you'd have to change it).
If you wanted to try the plugin route instead you just have to go to Plugins & Products and choose "add new plugin", choose the hook location you want and paste your code into the text area. Make up a title and make sure you enable it by clicking 'Yes'. (I wanted to mention this just in case, but since you've already gone through the trouble of creating a file for this you might as well keep going with that method). |
#5
|
|||
|
|||
Thank you for the help, with the information you have supplied things now seem to work , great job..
Yes you are correct, its the Sheduled tasks, not the cpanel cron i was thinking of using.. I have edited the code as below, its not 100% i need to look at how it creates the build and publish date, it now however creates the rss feed.. Thankyou. PHP Code:
Hello all. Thankyou again for the help....But i am now stuck again...help ok in the code above i had to do some things as if there was a ? or " in my event details then the rss page failed to load in the browser.. I did some checking and ? gets converted to £ and " gets converted to " My new rss page then displays as it should. If.. I use the rss widget code and enable the description to display the feed from inside the widget i get the symbols appear £ and " not ? and " I was going to add some php to the template to find and replace, looks like i cant do this? then i was looking at vb:raw and other areas like this? how can i add some code to a template take {vb:raw item.description} and find and replace characters before it displays on the browser? Many thanks in advance, below i will attach my new template code. my rss file shows ? : http://www.bidefordmarket.co.uk/bide...teventlist.rss My rss display shows the characters : http://www.bidefordmarket.co.uk vbcms_widget_rss_pageb PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|