Brief Description:
A snippet to show a feed in your page, suports RSS,XML
Quote from: theaslak at May 29, 2007, 07:40 AM
Quote from: jacksonfdam at Feb 05, 2007, 01:30 PM
Brief Description:
A snippet to show a feed in your page, suports RSS,XML
Thanks for your plugin! But i have a question: how i use a feed with a ? sign? like:
`http://picasaweb.google.nl/data/feed/base/user/dirkslandsmannenkoor?kind=album&alt=rss&hl=nl`
Scandinavian letters cause some problems. They are presented as question marks (?).
I don’t know about RSS-feeds at all, is it possible to compile several feeds into one feed?
Thanks for your plugin! But i have a question: how i use a feed with a ? sign? like:
`http://picasaweb.google.nl/data/feed/base/user/dirkslandsmannenkoor?kind=album&alt=rss&hl=nl`
<?php
/*
*
* A snippet to show a feed in your page, suports RSS,XML
*
*
* Parameters:
*
* &urlrss [string] (required)
* Define the URL of the RSS Feed
* &title [string] (required)
* Define the title of the RSS feed
* &level_deep [integer = 5]
* Define how many items you want to show
*&rss_ShowDesc [bool = 1]
* Set to 1 to show the description field under the link
*&rss_DescSplit [integer = 0]
* Number of character you want to show in the description, if there are more characters, they are deleted and replaced with " ...".
* Set it to 0 to show the entire description
*
*
* CSS Style class
*---------------------
*
* .rss_title
* Style for the title of your feed
* .rss_desc
* Style for the description of your feed
* .rss_copy
* Style for the copyright of your feed
* .rss_sub_title
* Style for title of the article
* .rss_sub_pubdate
* Style for publication date of the article
* .rss_sub_desc
* Style for description of the article (only if rss_ShowDesc = 1)
*
*
*
* Example snippet call:
* ---------------------
*
* [[RssReader? &urlrss=`http://rss.terra.com.br/0,,EI4795,00.xml`]]
*
* No configuration needed in snippet code, so don't go below this point unless
* you know what you're doing.
*/
function xml_rss_reader($xml_parse,$deep,$ShowDesc,$DescSplit)
{
$xml = simplexml_load_string($xml_parse);
$return = "<h4 class='rss_title'>".$xml->channel[0]->title."</h4>"
. "<span class='rss_desc'>" . $xml->channel[0]->description."</span><br/>"
. "<span class='rss_copy'>" . $xml->channel[0]->copyright."</span><br/>";
//$img = $xml->channel[0]->image[0]->url[0];
//if(!empty($img)){$return .= "<img src='$img' class='rss_img'><br/>";}caso queira que apareça a img
for( $i=0 ; $i < $deep ; $i++ ){
$title = $xml->channel[0]->item[$i]->title[0];
$link = $xml->channel[0]->item[$i]->link[0];
$pubDate = $xml->channel[0]->item[$i]->pubDate[0];
$return .= "<a href='$link' target='_blank' class='rss_sub_title'>".($title)."</a> - <span class='rss_sub_pubdate'> " . $pubDate . "</span><br/>" ;
if ($ShowDesc)
{
$description = $xml->channel[0]->item[$i]->description[0];
$description = ($DescSplit != 0) ? substr($description, 0, $DescSplit) . " ..." : $description ;
$return .= "<span class='rss_sub_desc'>" . $description . "</span>
<br/>";
}
}
return $return ;
}
// Default settings
$urlrss=(isset($urlrss)) ? $urlrss : "http://www.jacksonfdam.com.br/index.php?id=11";
$title=(isset($title)) ? $title : "RSS feed";
$level_deep = (isset($level_deep)) ? (settype($level_deep,"integer")) ? $level_deep : 5 : 5;
$rss_ShowDesc = (isset($rss_ShowDesc)) ? $rss_ShowDesc : 1 ;
$rss_DescSplit = (isset($rss_DescSplit)) ? (settype($rss_DescSplit,"integer")) ? $rss_DescSplit : 0 : 0;
echo '<h3 class="rss_title">'.$title.'</h3>';
if (!($fp = fopen($urlrss, "r"))) {
echo "Error loading Xml File"; //Error loading Xml File
} else {
$xml_parse="";
while ($data = fread($fp, 4096)){
$xml_parse .= $data;
}
echo xml_rss_reader($xml_parse,$level_deep,$rss_ShowDesc,$rss_DescSplit); // function to create the html content
$xml_parse="";
}
?>
<?php
function xml_rss_reader($xml_parse,$deep,$ShowDesc,$DescSplit)
{
$xml = simplexml_load_string($xml_parse);
$return = "<h4 class='rss_title'>".$xml->channel[0]->title."</h4>"
. "<span class='rss_desc'>" . $xml->channel[0]->description."</span><br/>"
. "<span class='rss_copy'>" . $xml->channel[0]->copyright."</span><br/>";
//$img = $xml->channel[0]->image[0]->url[0];
//if(!empty($img)){$return .= "<img src='$img' class='rss_img'><br/>";}caso queira que apareça a img
for( $i=0 ; $i < $deep ; $i++ ){
$title = $xml->channel[0]->item[$i]->title[0];
$link = $xml->channel[0]->item[$i]->link[0];
$pubDate = $xml->channel[0]->item[$i]->pubDate[0];
$return .= "<a href='$link' target='_blank' class='rss_sub_title'>".($title)."</a> - <span class='rss_sub_pubdate'> " . $pubDate . "</span><br/>" ;
if ($ShowDesc)
{
$description = $xml->channel[0]->item[$i]->description[0];
$description = ($DescSplit != 0) ? substr($description, 0, $DescSplit) . " ..." : $description ;
$return .= "<span class='rss_sub_desc'>" . $description . "</span>
<br/>";
}
}
return $return ;
}
?><?php
/*
*
* A snippet to show a feed in your page, suports RSS,XML
*
*
*
* Install note
* --------------
*
* Create a folder RssReader in assets/snippets/
* Upload the file "function.xml_rss_reader.php" in the new folder (assets/snippets/RssReader/)
* Copy this file into a new snippet called RssReader
*
* Example snippet call:
* --------------------------
*
* [[RssReader? &urlrss=`http://rss.terra.com.br/0,,EI4795,00.xml`]]
*
*
*
*
*
* Parameters:
* ---------------
*
* &urlrss [string] (required)
* Define the URL of the RSS Feed
* &title [string] (required)
* Define the title of the RSS feed
* &level_deep [integer = 5]
* Define how many items you want to show
*&rss_ShowDesc [bool = 1]
* Set to 1 to show the description field under the link
*&rss_DescSplit [integer = 0]
* Number of character you want to show in the description, if there are more characters, they are deleted and replaced with " ...".
* Set it to 0 to show the entire description
*
*
* CSS Style class
*---------------------
*
* .rss_title
* Style for the title of your feed
* .rss_desc
* Style for the description of your feed
* .rss_copy
* Style for the copyright of your feed
* .rss_sub_title
* Style for title of the article
* .rss_sub_pubdate
* Style for publication date of the article
* .rss_sub_desc
* Style for description of the article (only if rss_ShowDesc = 1)
*
*
*
*
*
*
* No configuration needed in snippet code, so don't go below this point unless
* you know what you're doing.
*/
include_once($modx->config['base_path'].'assets/snippets/RssReader/function.xml_rss_reader.php');
// Default settings
$urlrss=(isset($urlrss)) ? $urlrss : "http://www.jacksonfdam.com.br/index.php?id=11";
$title=(isset($title)) ? $title : "RSS feed";
$level_deep = (isset($level_deep)) ? (settype($level_deep,"integer")) ? $level_deep : 5 : 5;
$rss_ShowDesc = (isset($rss_ShowDesc)) ? $rss_ShowDesc : 1 ;
$rss_DescSplit = (isset($rss_DescSplit)) ? (settype($rss_DescSplit,"integer")) ? $rss_DescSplit : 0 : 0;
echo '<h3 class="rss_title">'.$title.'</h3>';
if (!($fp = fopen($urlrss, "r"))) {
echo "Error loading Xml File"; //Error loading Xml File
} else {
$xml_parse="";
while ($data = fread($fp, 4096)){
$xml_parse .= $data;
}
echo xml_rss_reader($xml_parse,$level_deep,$rss_ShowDesc,$rss_DescSplit); // function to create the html content
$xml_parse="";
}
?>[[feedreader? &urlrss=`http://www.redwinebuzz.com/winesooth/feed` &title=`wine sooth`]]