Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

RSS feed plugin

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Fri Jun 13, 2003 8:44 pm    Post subject: RSS feed plugin Reply with quote

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
View user's profile Send private message Visit poster's website
Hinrich
Smarty Rookie


Joined: 18 Apr 2003
Posts: 33

PostPosted: Sat Jun 14, 2003 12:44 pm    Post subject: Reply with quote

I just added another plugin for the MagpieRSS library.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Jun 14, 2003 12:55 pm    Post subject: Reply with quote

@Hinrich: where did you add it? I use Magpie and I haven't gotten around to wrapping it yet.

thanks..
Back to top
View user's profile Send private message
Hinrich
Smarty Rookie


Joined: 18 Apr 2003
Posts: 33

PostPosted: Sun Jun 15, 2003 10:05 am    Post subject: Reply with quote

Here: http://smarty.incutio.com/?page=SmartyPlugins
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Jun 15, 2003 11:23 pm    Post subject: Reply with quote

@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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Mon Jun 16, 2003 2:44 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Jun 16, 2003 3:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Hinrich
Smarty Rookie


Joined: 18 Apr 2003
Posts: 33

PostPosted: Mon Jun 16, 2003 8:10 am    Post subject: Reply with quote

I agree. A system like on php.resourceindex.com should be a good solution.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Jun 16, 2003 9:16 am    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Mon Jun 16, 2003 1:51 pm    Post subject: Reply with quote

If you find a good one I have no problem installing it.
Back to top
View user's profile Send private message Visit poster's website
Duncan
Smarty Pro


Joined: 16 Dec 2003
Posts: 166

PostPosted: Sat Feb 28, 2004 11:36 am    Post subject: Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Feb 28, 2004 11:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Duncan
Smarty Pro


Joined: 16 Dec 2003
Posts: 166

PostPosted: Sun Feb 29, 2004 12:04 am    Post subject: Reply with quote

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 Smile
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
View user's profile Send private message
johannes
Smarty Regular


Joined: 10 May 2003
Posts: 85
Location: Malmö, Sweden

PostPosted: Tue Mar 09, 2004 7:39 am    Post subject: agree Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Bajki
Smarty Rookie


Joined: 11 Jul 2006
Posts: 9

PostPosted: Thu Aug 24, 2006 4:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP