Jump to content
  • 0

Help with rss feed


Caves

Question


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  14
  • Reputation:   0
  • Joined:  06/27/14
  • Last Seen:  

Hi, I'm using Brightix's released flux layout and I'm wondering how can i make the rss feed become topics from my Forum?
 

<?php
/*
	RSS Extractor and Displayer
	(c) 2007-2010  Scriptol.com - Licence Mozilla 1.1.
	rsslib.php
	
	Requirements:
	- PHP 5.
	- A RSS feed.
	
	Using the library:
	Insert this code into the page that displays the RSS feed:
	
	<?php
	require_once("rsslib.php");
	echo RSS_Display("http://www.xul.fr/rss.xml", 15);
	?>
	
*/

$RSS_Content = array();

function RSS_Tags($item, $type)
{
		$y = array();
		$tnl = $item->getElementsByTagName("title");
		$tnl = $tnl->item(0);
		$title = $tnl->firstChild->textContent;

		$tnl = $item->getElementsByTagName("link");
		$tnl = $tnl->item(0);
		$link = $tnl->firstChild->textContent;
		
		$tnl = $item->getElementsByTagName("pubDate");
		$tnl = $tnl->item(0);
		$date = $tnl->firstChild->textContent;		

		$tnl = $item->getElementsByTagName("description");
		$tnl = $tnl->item(0);
		$description = $tnl->firstChild->textContent;

		$y["title"] = $title;
		$y["link"] = $link;
		$y["date"] = $date;		
		$y["description"] = $description;
		$y["type"] = $type;
		
		return $y;
}


function RSS_Channel($channel)
{
	global $RSS_Content;

	$items = $channel->getElementsByTagName("item");
	
	// Processing channel
	
	$y = RSS_Tags($channel, 0);		// get description of channel, type 0
	array_push($RSS_Content, $y);
	
	// Processing articles
	
	foreach($items as $item)
	{
		$y = RSS_Tags($item, 1);	// get description of article, type 1
		array_push($RSS_Content, $y);
	}
}

function RSS_Retrieve($url)
{
	global $RSS_Content;

	$doc  = new DOMDocument();
	$doc->load($url);

	$channels = $doc->getElementsByTagName("channel");
	
	$RSS_Content = array();
	
	foreach($channels as $channel)
	{
		 RSS_Channel($channel);
	}
	
}


function RSS_RetrieveLinks($url)
{
	global $RSS_Content;

	$doc  = new DOMDocument();
	$doc->load($url);

	$channels = $doc->getElementsByTagName("channel");
	
	$RSS_Content = array();
	
	foreach($channels as $channel)
	{
		$items = $channel->getElementsByTagName("item");
		foreach($items as $item)
		{
			$y = RSS_Tags($item, 1);	// get description of article, type 1
			array_push($RSS_Content, $y);
		}
		 
	}

}


function RSS_Links($url, $size = 15)
{
	global $RSS_Content;

	$page = "<ul>";

	RSS_RetrieveLinks($url);
	if($size > 0)
		$recents = array_slice($RSS_Content, 0, $size + 1);

	foreach($recents as $article)
	{
		$type = $article["type"];
		if($type == 0) continue;
		$title = $article["title"];
		$link = $article["link"];
		$page .= "<li><a href=\"$link\">$title</a></li>\n";			
	}

	$page .="</ul>\n";

	return $page;
}



function RSS_Display($url, $size = 15, $site = 0, $withdate = 0)
{
	global $RSS_Content;

	$opened = false;
	$page = "";
	$site = (intval($site) == 0) ? 1 : 0;

	RSS_Retrieve($url);
	if($size > 0)
		$recents = array_slice($RSS_Content, $site, $size + 1 - $site);

	$i = 0;
	foreach($recents as $article)
	{
		$type = $article["type"];
		if($type == 0)
		{
			if($opened == true)
			{
				$page .="\n";
				$opened = false;
			}
			$page .="<b>";
		}
		else
		{
			if($opened == false) 
			{
				$page .= "\n";
				$opened = true;
			}
		}
		$title = $article["title"];
		$link = $article["link"];
		if (strlen($title) > 30) {
			$title = substr($title,0, 30);
		}
		$date = $article["date"];
		$page .= "<table cellspacing=\"0\" cellpadding=\"0\" class=\"rss\">
					<tr>
						<td colspan=\"2\" class='title'>
							<a target=\"_blank\" href=\"$link\">$title</a>
						</td>
					</tr>
					<tr class=\"timesetting\">
						<td align=\"left\">
							on " . date("<font color=\"#525252\">l,g:ia</font>",strtotime($date)). "
						</td>
						<td align=\"right\" class='date'>
							".strftime("<font color=\"#525252\">%d/%m/%Y</font>",strtotime($date))."
						</td>
					</tr>
				</table>";
	}

	if($opened == true)
	{
		$page .="\n";
		$page .="\n";
	}
	return $page."\n";
}
?>
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

echo RSS_Display("http://www.xul.fr/rss.xml", 15);

change to your forum RSS link.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  66
  • Topics Per Day:  0.01
  • Content Count:  223
  • Reputation:   4
  • Joined:  02/23/12
  • Last Seen:  

where to change this?? 

Link to comment
Share on other sites

×
×
  • Create New...