Posts Tagged ‘rss’

RSS reader in PHP, compatible with ccHost 4.5

diumenge, març 8th, 2009

Here a plugin for ccHost 4.5 or 5 to get RSS feeds and show them on your cchost_files/*.xml . It may be used out of ccHost without problems. Written in PHP5. License GPL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
function getRSS($feed, $limit = 3) {
    // $feed must be a valid RSS url.
    // the function will return an array with the basic information for our news.
    // print_r($RSSData); for further information.
    // License: GPL  - Eduard Gamonal <edu at eduard-gamonal dot net>
 
    $feedData = file_get_contents($feed);
    $RSSData = new SimpleXMLElement($feedData);
 
    $news = array();
 
    $c = count($RSSData->channel->item);
    for ($i = 0; $i < $limit  and $i < $c; $i++) {
        $news[$i]['title'] = (string)$RSSData->channel->item[$i]->title;
        $news[$i]['link'] = (string)$RSSData->channel->item[$i]->link;
        $news[$i]['pubDate'] = (string)$RSSData->channel->item[$i]->pubDate;
        $news[$i]['description'] = (string)$RSSData->channel->item[$i]->description;
    }
 
    return $news;
}
?>

ccHost plugin: RSS feeds reader

divendres, setembre 5th, 2008

Developing MusicaLliure.net I created a plugin to get and show RSS feeds.

It’s PHP5, it works with ccHost 4.5 or 5. Not tested in previous versions.

License GPL 2 or later.

Download ccHost plugin: RSS feeds reader

You shall place this extra in cchost_files/lib. In  viewfile/*.xml you may include these lines:

<tal:block define=”news
php:getRSS(‘http://www.musicalliure.net/bloc/feed/‘, 2)” />

<ul class=”home_news”>
<li tal:repeat=”item news”><h4><a href=”${item/link}”>${item/title}</a></h4> ${item/pubDate}<br
/>${item/description}</li>
</ul>

Complement per a ccHost: lector de RSS

divendres, setembre 5th, 2008

Programant per MusicaLliure.net he fet un complement per a ccHost 4.5. Es tracta d’una funció que llegeix feeds RSS i els mostra per pantalla. La finalitat és mostrar les últimes novetats publicades en un bloc adjunt a MusicaLliure.net, però a la portada de la web.

PHP5. Funciona amb ccHost 4.5 i potser amb ccHost 5. No està provat en altres versions.

Download ccHost plugin: RSS feeds reader

Heu de desar-lo a cchost_files/lib. A  viewfile/*.xml podeu incloure les línies següents:

<ul class="home_news">
<li tal:repeat="item news"><h4><a href="${item/link}">${item/title}</a></h4> ${item/pubDate}<br
/>${item/description}</li>
</ul>

Entra