vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - [WIDGET] Upcoming Events (https://vborg.vbsupport.ru/showthread.php?t=236402)

4thstar 01-21-2013 09:42 PM

Hello all.
I hope you dont mind me asking here, i wanted to create an rss feed for my events, i dont know php so its all trial and error for me..

I have edited the code as below which creates afilename.rss, when this file is called it shows an rss feed..

i had issues with some strange characters breaking the page but things seem ok..

I currently have this on my index page as a widget, it cant stay there as it will create to much server work.

Question...

can this be turned into a php file to run as a sheduled task? If so how?

many thanks in advance.

Carl

PHP Code:

ob_start(); 
global $db,$vbulletin; 
$calendarid="1"; 
$per_page = "60"; 
//################################################ 
$d=date("d"); 
$m=date("m"); 
$y=date("y"); 
$sdate = mktime(0, 0, 0, date("$m"), date("$d"),  date("$y")); 
$edate = mktime(0, 0, 0, date("$m"), date("31"),  date("$y")); 
$and=" and dateline_from >= '".$sdate."'"; 

$getevents=$db->query_read("SELECT eventid, event, title, customfields, dateline_from from " . TABLE_PREFIX . "event WHERE calendarid='".$calendarid."' $and order by dateline_from ASC LIMIT $per_page"); 
$count=0; 
if(!$db->num_rows($getevents)) 


else 

WHILE ($events=$db->fetch_array($getevents)) 

$eventdetails=$events['event'];
$eventdetails=substr($eventdetails, 0, 300);
$eventdetails .= "......";
$customfield=$events['customfields'];
$customfield = str_replace('a:0:{}', '', $customfield );
$customfield =strstr ($customfield, '"');
$customfield = str_replace('"', '', $customfield );
$customfield = str_replace(';}', '', $customfield );

$dtitle=$events['title']; 
$did=$events['eventid']; 
$date = vbdate('d-m-y',$events['dateline_from'], false,true,false,true); 
$dateext = vbdate('l jS F Y',$events['dateline_from'], false,true,false,true);
if ($count = 2){$class="alt2";}else {$class="alt1";} 
$year=date("Y"); 
$pagetitle = $f; 
$pagetitle .= " "; 
$pagetitle.=$year; 
$eventbits .=""; 

$dateext = htmlentities($dateext);
$eventdetails = htmlentities($eventdetails);


$eventbitsExt .="
<item>
<title>$dateext</title>
<description><![CDATA[$eventdetails]]></description>
<link><![CDATA[http://www.bidefordmarket.co.uk/calendar.php?do=getinfo&e=$did&c=$calendarid]]></link>
<guid><![CDATA[000000$did]]></guid>
<pubDate><![CDATA[$sdate]]></pubDate>
</item>
"; 
$count++; 




$bidefordmarketeventlist = "bidefordmarketeventlist.rss";
$fh = fopen($bidefordmarketeventlist, 'w') or die("can't open file");
fwrite($fh, "<?xml version='1.0' encoding='UTF-8' ?>
<rss version='2.0'>
<channel>
<title>Bideford Market Events</title>
<description>This is the RSS feed for Bideford Markets Latest Events</description>
<link>http://www.bidefordmarket.co.uk</link>
<lastBuildDate>$sdate</lastBuildDate>
<pubDate>$sdate</pubDate>
<ttl>1800</ttl>
");

//$eventbitsExt = str_replace("?", "?", $eventbitsExt);
//$eventbitsExt = str_replace("&", "&", $eventbitsExt);

$strfinda .= chr(150);
$eventbitsExt = str_replace($strfinda, " ", $eventbitsExt);


fwrite($fh, $eventbitsExt);
fwrite($fh, "</channel>
</rss>");
fclose($fh);


$db->free_result($getevents); 
unset($events); 
$output=ob_get_contents(); 
ob_end_clean();

yes i know i probably look very tatty in the way i did things, but i am a novice with php :)

89Brian 02-01-2013 04:21 PM

Did anyone ever figure out how to add a cut off date for events to be displayed?

I'd like to have a 20 or 30 day cut off on displayed events.

fxdigi-cash 05-06-2013 03:22 AM

Thanks for the mod!

I believe it would be more interesting if you added jquery count down till event time... what do you think?

PAPPACLART 01-05-2014 04:42 AM

support for 4.2.2? As no longer works for me

Daniel 10-12-2014 08:18 AM

Doesn't seem to work for 4.2.2

oldfan 04-15-2023 03:26 PM

works for 4.2..6 php 7.2

anyway to get it to show like every april 12, multiple years?


All times are GMT. The time now is 03:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01099 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete