View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jun 13, 2003 8:44 pm Post subject: RSS feed plugin |
|
|
I needed an RSS feed plugin for a project, so I thought I'd contribute it here. It requires the ONYX RSS library available at http://www.readinged.com/onyx/rss/. PHP also has to be compiled --with-xml.
[php:1:c89ba3759c]
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: rss_load
* Version: 1.0
* Date: June 13, 2003
* Author: Monte Ohrt <monte@ispi.net>
* Purpose: fetch rss feed, assign to template var
* Requires: * php must be compiled --with-xml
* * onyx rss lib: http://www.readinged.com/onyx/rss/
* Install: * put onyx-rss.php in include_php path
* * put function.rss_load.php in plugin dir
* * call from within a template
*
* Input: file = local file or URL of rss
* assign = template var to assign parsed data
* caching = true/false (opt, default true)
* cache_dir = directory to store cache (opt,
* default=$smarty->cache_dir)
* cache_lifetime = number of seconds cache file
* is valid (opt, default=3600)
* debug_mode = sets onyx debug mode (opt)
*
* Examples: {rss_load
* file="http://www.php.net/news.rss"
* assign="phpnews"}
* {section name=rss loop=$phpnews.items}
* <a href="{$phpnews.items[rss].link}">
* {$phpnews.items[rss].title}</a><br>
* {/section}
* -------------------------------------------------------------
*/
function smarty_function_rss_load($params, &$smarty)
{
if ($params['file'] == '') {
$smarty->trigger_error("rss_load: missing 'file' parameter");
return;
}
if ($params['assign'] == '') {
$smarty->trigger_error("rss_load: missing 'assign' parameter");
return;
}
require_once('onyx-rss.php');
if(class_exists('ONYX_RSS')) {
$_rss =& new ONYX_RSS();
if(isset($params['cache_dir'])) {
$_rss->setCachePath($params['cache_dir']);
} else {
$_rss->setCachePath($smarty->cache_dir);
}
if(isset($params['cache_lifetime'])) {
$_rss->setExpiryTime($params['cache_lifetime']);
} else {
$_rss->setExpiryTime(3600); // one hour
}
if(isset($params['debug_mode'])) {
$_rss->setDebugMode($params['debug_mode']);
}
if(!isset($params['caching']) || $params['caching']) {
$_cache_file = 'rss_cache.' . urlencode($params['file']);
} else {
$_cache_file = null;
}
if($_rss->parse($params['file'], $_cache_file)) {
$smarty->assign($params['assign'], $_rss->RSSData);
} else {
$smarty->trigger_error("rss_load: unable to read '". $params['file'] . "'");
}
} else {
$smarty->trigger_error("rss_load: unable to load ONYX_RSS library");
}
}
/* vim: set expandtab: */
?>[/php:1:c89ba3759c] |
|
Back to top |
|
Hinrich Smarty Rookie
Joined: 18 Apr 2003 Posts: 33
|
Posted: Sat Jun 14, 2003 12:44 pm Post subject: |
|
|
I just added another plugin for the MagpieRSS library. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Jun 14, 2003 12:55 pm Post subject: |
|
|
@Hinrich: where did you add it? I use Magpie and I haven't gotten around to wrapping it yet.
thanks.. |
|
Back to top |
|
Hinrich Smarty Rookie
Joined: 18 Apr 2003 Posts: 33
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun Jun 15, 2003 11:23 pm Post subject: |
|
|
@Hinrich: sigh. I should have looked there myself. Thanks for the link.
It seems to me that the plugin situation isn't really conducive to sharing amongst community members with plugins spread between the official site, the wiki and here as well.
A shared plugin library management tool--that would make a good project for somone who has some time.... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 16, 2003 2:44 am Post subject: |
|
|
I think this forum would be a sufficient tool so long as we organize it well. We can migrate the existing stuff over here. The forum supplies a nice browse by subject, search by any content, and message threads on the plugins of course.
Monte |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Jun 16, 2003 3:46 am Post subject: |
|
|
hmmm. Doesn't really fit the bill as a repository, I think. Focusing on the positive though, it would be nice to have a single source and it makes sense to have something organized here, especially since the forums do have nice features, as Monte points out. Sometime I will get around to reviewing the bb code to see about adding a download button to code snippets. Another feature I think handy would be a way to sort the topics from within a forum (other than by most recent post). |
|
Back to top |
|
Hinrich Smarty Rookie
Joined: 18 Apr 2003 Posts: 33
|
Posted: Mon Jun 16, 2003 8:10 am Post subject: |
|
|
I agree. A system like on php.resourceindex.com should be a good solution. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Jun 16, 2003 9:16 am Post subject: |
|
|
Another useful link--thanks again!
Perhaps simply a public CVS or Sourceforge umbrella project? Of course, I don't want it to get complicated, but a single location of maintained sources would be pleasant. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 16, 2003 1:51 pm Post subject: |
|
|
If you find a good one I have no problem installing it. |
|
Back to top |
|
Duncan Smarty Pro
Joined: 16 Dec 2003 Posts: 166
|
Posted: Sat Feb 28, 2004 11:36 am Post subject: |
|
|
Just found this plugin in the wiki list and would like to give it a try, but the provided ONYX RSS URL no longer resolves to where it's supposed to be - instead of an RSS library I got flooded with ebay links and popup ads.
Is that library no longer maintained or did they move somewhere else?
I checked via google and all references I found still point to the above mentioned URL. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Feb 28, 2004 11:52 pm Post subject: |
|
|
Yep. I noticed this several months ago--it vanished off the web. Luckily, it was released under a very generous public licence; you can grab a zip'ed copy from me (only temporary). It includes Monte's plugin for Smarty.
In the long run, it would be nice if someone could host the library. Perhaps we can add it to this server? |
|
Back to top |
|
Duncan Smarty Pro
Joined: 16 Dec 2003 Posts: 166
|
Posted: Sun Feb 29, 2004 12:04 am Post subject: |
|
|
boots wrote: | Yep. I noticed this several months ago--it vanished off the web. Luckily, it was released under a very generous public licence; you can grab a zip'ed copy from me (only temporary). It includes Monte's plugin for Smarty. | Ah,
excellent - thanks a lot
boots wrote: | In the long run, it would be nice if someone could host the library. Perhaps we can add it to this server? | That would be excellent and if that's possible then the URLs should be changed in the Wiki as well.
btw: if that's not possible then simply let me know and I will host the file. |
|
Back to top |
|
johannes Smarty Regular
Joined: 10 May 2003 Posts: 85 Location: Malmö, Sweden
|
Posted: Tue Mar 09, 2004 7:39 am Post subject: agree |
|
|
Hi, I agree on the sugesstion to make a plugin directory on the smarty site.
The plug coding style is the reason form me and many others to work whit Smarty and it would be nice to speed the Smarty-users work on writing plugins.
Lok att the Pear packages page http://pear.php.net/packages.php, mayby a Smarty plugin page in this style?
just an idea! / JohannesF _________________ --------------------------
nice culture on the Internet
www.poeter.se |
|
Back to top |
|
Bajki Smarty Rookie
Joined: 11 Jul 2006 Posts: 9
|
Posted: Thu Aug 24, 2006 4:58 pm Post subject: |
|
|
hi !
How can i connect it with OverLib plugin ?
I've made sth like this :
Code: | {capture name="newsy"}
{rss_load file="http://rss.gazeta.pl/pub/rss/deser.xml" assign="phpnews"}
{section name=rss loop=$phpnews.items max=5}
<a href="{$phpnews.items[rss].link}">
{$phpnews.items[rss].title}</a><br>
{/section}
{/capture}
Statystyki :
<a href="/zin/statystyki#news" {popup text=`$smarty.capture.newsy` fgcolor="#FFFFFF" bgcolor="#EDEDED"}>Newsy ({liczba_newsow})</a> |
And the output is very ugly :/ :
Pls help ! |
|
Back to top |
|
|