We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13357
    • 0 Posts
    This is an auto-generated support/comment thread for feedreader.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    A snippet to show a feed in your page, suports RSS,XML
      • 2762
      • 1,198 Posts
      cool! thanks for sharing smiley
        Free MODx Graphic resources and Templates www.tattoocms.it
        -----------------------------------------------------

        MODx IT  www.modx.it
        -----------------------------------------------------

        bubuna.com - Web & Multimedia Design
        • 29649
        • 3 Posts
        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?
          • 18282
          • 4 Posts
          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`
            • 15309
            • 30 Posts
            Quote from: MarFra at Oct 09, 2007, 12:21 PM

            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`

            Quote from: theaslak at May 29, 2007, 07:40 AM

            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?


            NO one seems to reply on the topic..??

            please help..
              • 3638
              • 21 Posts
              Quote from: MarFra at Oct 09, 2007, 12:21 PM

              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`

              I think you can use the HTML code for the question mark : ? = ?
              Don’t know if it works.



              Well, I’ve made some change to this FeedReader, with more option like number of article, show description, etc.
              Also, I’ve deleted utf8_decode function call on the rss feed (because I use utf8).
              Now you have CSS class to style the rss feed.

              Here it goes (copy and paste to a new snippet called RssReader) :
              <?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="";
              	}
              ?>



              Hope this help ... wink
                • 27305
                • 173 Posts
                When I add two feeds to the same page, it breaks my page, it just shows a white screen.
                  I made my first site with modx
                  ------------------------
                  Shopping blog
                  Sky+ HD
                  • 3638
                  • 21 Posts
                  Your problem is that when you call this snippet twice, the xml_rss_reader() function is also redefined twice, so i think the parser bug.

                  How to solve :

                  • Create a file called function.xml_rss_reader.php
                  • Open it and paste this (this is the xml_rss_reader function) :
                  <?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 ;
                  }
                  	
                  ?>


                  • Upload this file in assets/snippets/RssReader/ (create folder RssReader).
                  • Go to your Manager, Ressources tab, Snippets tab, and edit the RssReader snippet
                  • Replace all the contents by this (note the include_once which call the file you just upload) :
                  <?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="";
                  	}
                  ?>


                  • It should be OK now !

                  It works with me. Tell me how it goes for you.

                  EDIT ; Updated the PHP Snippet code to add install instruction
                    • 27305
                    • 173 Posts
                    Thanks, wow what a response, will try this tonight when I get home from work.

                    cheers
                    Simon
                      I made my first site with modx
                      ------------------------
                      Shopping blog
                      Sky+ HD
                      • 12121
                      • 22 Posts
                      I am having trouble displaying anything using the feed reader.

                      my feed url is: www.redwinebuzz.com/winesooth/feed

                      my feedreader tag is:

                       [[feedreader? &urlrss=`http://www.redwinebuzz.com/winesooth/feed` &title=`wine sooth`]] 


                      what am I doing wrong?

                      Please help!