|
|
#1 |
|
New Member
![]() Join Date: Jan 2012
Posts: 3
|
Hi!
I need help displaying an RSS feed on my website which updates over time, but I only want to include those items which are in a certain category. Is there any way of doing this? Any help would be appreciated! |
|
|
|
|
|
#2 |
|
Gold Member
![]() Join Date: Oct 2008
Location: Ireland
Posts: 349
|
It depends on a few things. How is the rss generated? if it's a wordpress blog then I'm pretty sure you can filter by category very easily in the url. If not, you could write a PHP program which fetches the rss feed and then filters the results. Which of these cases are you looking for?
__________________
Conor |
|
|
|
|
|
#3 |
|
New Member
![]() Join Date: Jan 2012
Posts: 3
|
The RSS is from a blog but I don't think it's made in wordpress. Here is the url: http://www.blogg.circusoflamia.com and the RSS: http://circusoflamia.blogg.se/index.rss
I havn't found a way to filter with the url anyway... |
|
|
|
|
|
#4 |
|
Gold Member
![]() Join Date: Oct 2008
Location: Ireland
Posts: 349
|
Yeah don't think it will be possible to filter by URL with that blog.
Here's a quick PHP program which will fetch the rss feed, filter it by the $category variable and print the results: Code:
$category = 'Insanity';
$dom = new DOMdocument( );
$success = $dom->load( 'http://circusoflamia.blogg.se/index.rss' );
if( !$success )
die( 'failed to load url' );
$elements = $dom->getElementsByTagName( 'item' );
$items = array( );
foreach( $elements as $element ){
$item = array( );
if( $element->getElementsByTagName( 'category' )->item( 0 ) == $category ){
foreach( $element->childNodes as $node )
$item[ $node->nodeName ] = $node->nodeValue;
array_push( $items, $item );
}
}
die( print_r( $items ) );
__________________
Conor |
|
|
|
|
|
#5 |
|
New Member
![]() Join Date: Jan 2012
Posts: 3
|
Thanks a lot for the help!
|
|
|
|
![]() |
| Tags |
| category, display, rss |
| Thread Tools | |
| Display Modes | |
|
|