Ένα εύκολο σκριπτ που δημιουργεί ένα Eventlist rss feed.
Δεν χρειάζεται εγκατάσταση, απλώς αντιγραφή και επικόλληση στο βασικό joomla directory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
<?php // rss feed for eventlist 1.1 by SBZ systems - Solon Zenetzis // https://www.sbzsystems.com /* Initialize Joomla framework */ define( '_JEXEC', 1 ); define('JPATH_BASE', dirname(__FILE__) ); define( 'DS', DIRECTORY_SEPARATOR ); /* Required Files */ require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); /* To use Joomla's Database Class */ //require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' ); /* Create the Application */ $config = new JConfig(); $offset= $config->offset; $host = $config->host; $user = $config->user; $password = $config->password; $db = $config->db; $dbprefix = $config->dbprefix; $sitename = $config->sitename; $MetaDesc = $config->MetaDesc; $url =$_SERVER['HTTP_HOST']; ////////////// SETTINGS $limit_results=100; $limit_words=30; $logo='/images/stories/logo.jpg'; /////////////////////// //open database $link=mysql_connect("$host", $user, $password) or die(mysql_error()); mysql_select_db("$db") or die(mysql_error()); mysql_set_charset('utf8',$link); $query =' SELECT '.$dbprefix.'menu.id AS itemid, '.$dbprefix.'menu.name, title, datdescription, '.$dbprefix.'eventlist_events.id, '.$dbprefix.'menu.parent, '.$dbprefix.'eventlist_events.created FROM '.$dbprefix.'menu, '.$dbprefix.'eventlist_events, '.$dbprefix.'eventlist_cats_event_relations WHERE '.$dbprefix.'eventlist_cats_event_relations.itemid = '.$dbprefix.'eventlist_events.id AND '.$dbprefix.'menu.link LIKE CONCAT( \'%id=\', '.$dbprefix.'eventlist_cats_event_relations.catid ) AND '.$dbprefix.'eventlist_events.published =1 ORDER BY created DESC limit '.$limit_results; $data = mysql_query($query) or die(mysql_error()); ////////////////////// $rssfeed = '<?xml version="1.0" encoding="utf-8" ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>'.$sitename.'</title> <link>http://'.$url.'</link> <description>'.$MetaDesc .'</description> <image> <title>'.$sitename.'</title> <url>http://'.$url.$logo.'</url> <link>http://'.$url.'</link> </image>'; while($allcats = mysql_fetch_array($data)) { extract($allcats); if (date('Y', $created)<2000) { $created=date('r'); } else { $created=date('r',$created); } $maintext=cleantext($datdescription,$limit_words); if ($maintext) { $maintext=$maintext.'...<br><br>'; } $rssfeed .=' <item> <title>'.cleantext($title,0).'</title> <link>http://'.$url .'/index.php?option=com_eventlist&view=details&id='.$id.'&Itemid='.$itemid.'</link> <guid isPermaLink="false">http://'.$url .'/index.php?option=com_eventlist&view=details&id='.$id.'&Itemid='.$itemid.'</guid> <description><![CDATA['.$maintext.'('.$name.')]]></description> <pubDate>'.$created.'</pubDate> </item> '; //&Itemid=56 } $rssfeed .= '</channel> </rss>'; echo $rssfeed; ///clean text from html tags function cleantext($n,$c){ //keep image if ($c>0) { preg_match_all('/<img[^>]+>/i',$n, $image); } //clean html $n=strip_tags($n); $n=str_replace('&','&',($n)); //count words if ($c>0) { for ($i = 0; $i <= strlen( $n); $i++) { if (substr($n,$i,1) == ' ') { $keno++; if ($keno>$c) { break; } } } $n=$image[0][0].substr($n,0,$i); } return $n; } ?> |
Μπορείτε να αλλάξετε τις εξής 3 μεταβλητές:
$limit_results=the number of events
$limit_words=the number of words of each event
$logo=the logo jpg file