<?php
$rss = new DOMDocument();
$feed = array();
$urlarray = array(
array( 'name' => 'Fleet World', 'url' => 'https://fleetworld.co.uk/feed/' ),
array( 'name' => 'Standard/Transport', 'url' => 'http://www.standard.co.uk/news/transport/rss' ),
array( 'name' => 'londonist', 'url' => 'http://londonist.com/category/news/feed' ),
array( 'name' => 'Daily mail', 'url' => 'http://www.dailymail.co.uk/travel/index.rss' ),
);
foreach ( $urlarray as $url ) {
$rss->load( $url['url'] );
foreach ( $rss->getElementsByTagName( 'item' ) as $node ) {
$item = array(
'site' => $url['name'],
'title' => $node->getElementsByTagName( 'title' )->item( 0 )->nodeValue,
'desc' => $node->getElementsByTagName( 'description' )->item( 0 )->nodeValue,
'link' => $node->getElementsByTagName( 'link' )->item( 0 )->nodeValue,
'date' => $node->getElementsByTagName( 'pubDate' )->item( 0 )->nodeValue,
);
array_push( $feed, $item );
}
}
usort( $feed, function( $a, $b ) {
return strtotime( $b['date'] ) - strtotime( $a['date'] );
});
$limit = 5;
echo '<ul>';
for ( $x = 0; $x < $limit; $x++ ) {
$site = $feed[ $x ]['site'];
$title = str_replace( ' & ', ' & ', $feed[ $x ]['title'] );
$link = $feed[ $x ]['link'];
$description = $feed[ $x ]['desc'];
$date = date( 'l F d, Y', strtotime( $feed[ $x ]['date'] ) );
echo '<li style="padding:20px 0; border-bottom:1px solid #ccc;">';
echo '<strong>'.$site.':<br><a href="'.$link.'" title="'.$title.'" target="_blank">'.$title.'</a></strong><br>'.$description.'<br>('.$date.')';
echo '</li>';
}
echo '</ul>';
array_push( $feed, $item );
$content = $item['title'] . $item['description']
if (
(stripos($content, 'MODX') !== false) &&
(stripos($content, 'CMS') !== false) &&
(stripos($content, 'WordPress') === false)
) {
array_push( $feed, $item );
}
How about this:Thnk you so much for this Bob - but I'm getting a syntax error on the line:
Replace this line:
array_push( $feed, $item );
with this:
$content = $item['title'] . $item['description'] if ( (stripos($content, 'MODX') !== false) && (stripos($content, 'CMS') !== false) && (stripos($content, 'WordPress') === false) ) { array_push( $feed, $item ); }
if (
<?php
$rss = new DOMDocument();
$feed = array();
$urlarray = array(
array( 'name' => 'Fleet World', 'url' => 'https://fleetworld.co.uk/feed/' ),
array( 'name' => 'Standard/Transport', 'url' => 'http://www.standard.co.uk/news/transport/rss' ),
array( 'name' => 'londonist', 'url' => 'http://londonist.com/category/news/feed' ),
array( 'name' => 'Daily mail', 'url' => 'http://www.dailymail.co.uk/travel/index.rss' ),
);
foreach ( $urlarray as $url ) {
$rss->load( $url['url'] );
foreach ( $rss->getElementsByTagName( 'item' ) as $node ) {
$item = array(
'site' => $url['name'],
'title' => $node->getElementsByTagName( 'title' )->item( 0 )->nodeValue,
'desc' => $node->getElementsByTagName( 'description' )->item( 0 )->nodeValue,
'link' => $node->getElementsByTagName( 'link' )->item( 0 )->nodeValue,
'date' => $node->getElementsByTagName( 'pubDate' )->item( 0 )->nodeValue,
);
$content = $item['title'] . $item['description']
if (
(stripos($content, 'MODX') !== false) &&
(stripos($content, 'CMS') !== false) &&
(stripos($content, 'WordPress') === false)
) {
array_push( $feed, $item );
}
}
}
usort( $feed, function( $a, $b ) {
return strtotime( $b['date'] ) - strtotime( $a['date'] );
});
$limit = 5;
echo '<ul>';
for ( $x = 0; $x < $limit; $x++ ) {
$site = $feed[ $x ]['site'];
$title = str_replace( ' & ', ' & ', $feed[ $x ]['title'] );
$link = $feed[ $x ]['link'];
$description = $feed[ $x ]['desc'];
$date = date( 'l dS F Y, g.ia', strtotime( $feed[ $x ]['date'] ) );
echo '<li style="padding:20px 0; font-size:16px; line-height:140%; border-bottom:1px solid #ccc;">';
echo '<strong>'.$site.':<br><a href="'.$link.'" title="'.$title.'" target="_blank">'.$title.'</a></strong><br>'.$description.'<br><p style="padding-top:5px;font-style:italic; font-size:12px;">'.$date.'</p>';
echo '</li>';
}
echo '</ul>';
$content = $item['title'] . $item['description']
$content = $item['title'] . $item['description'];
if ( ((stripos($content, 'MODX') !== false) && (stripos($content, 'CMS') !== false)) || (stripos($content, 'WordPress') === false) )
Sorry about the typo. Also, it should be:
if ( ((stripos($content, 'MODX') !== false) && (stripos($content, 'CMS') !== false)) || (stripos($content, 'WordPress') === false) )
That would require both (MODX and CMS) and filter out WordPress, which is how I read your request.
You must have your RSS feed code set to limit things to 5 items. If you're using getResources anywhere in the process, the default &limit is 5.
<?php
$rss = new DOMDocument();
$feed = array();
$urlarray = array(
array( 'name' => 'Fleet World', 'url' => 'https://fleetworld.co.uk/feed/' ),
array( 'name' => 'Standard/Transport', 'url' => 'http://www.standard.co.uk/news/transport/rss' ),
array( 'name' => 'londonist', 'url' => 'http://londonist.com/category/news/feed' ),
array( 'name' => 'Daily mail', 'url' => 'http://www.dailymail.co.uk/travel/index.rss' ),
);
foreach ( $urlarray as $url ) {
$rss->load( $url['url'] );
foreach ( $rss->getElementsByTagName( 'item' ) as $node ) {
$item = array(
'site' => $url['name'],
'title' => $node->getElementsByTagName( 'title' )->item( 0 )->nodeValue,
'desc' => $node->getElementsByTagName( 'description' )->item( 0 )->nodeValue,
'link' => $node->getElementsByTagName( 'link' )->item( 0 )->nodeValue,
'date' => $node->getElementsByTagName( 'pubDate' )->item( 0 )->nodeValue,
);
$content = $item['title'] . $item['description'];
if (
((stripos($content, 'MODX') !== false) &&
(stripos($content, 'CMS') !== false)) ||
(stripos($content, 'Wordpress') === false)
) {
array_push( $feed, $item );
}
}
}
usort( $feed, function( $a, $b ) {
return strtotime( $b['date'] ) - strtotime( $a['date'] );
});
$limit = 5;
echo '<ul>';
for ( $x = 0; $x < $limit; $x++ ) {
$site = $feed[ $x ]['site'];
$title = str_replace( ' & ', ' & ', $feed[ $x ]['title'] );
$link = $feed[ $x ]['link'];
$description = $feed[ $x ]['desc'];
$date = date( 'l dS F Y, g.ia', strtotime( $feed[ $x ]['date'] ) );
echo '<li style="padding:20px 0; font-size:16px; line-height:140%; border-bottom:1px solid #ccc;">';
echo '<strong>'.$site.':<br><a href="'.$link.'" title="'.$title.'" target="_blank">'.$title.'</a></strong><br>'.$description.'<br><p style="padding-top:5px;font-style:italic; font-size:12px;">'.$date.'</p>';
echo '</li>';
}
echo '</ul>';
(stripos($content, '') === false)
((stripos($content, 'MODX') !== false) &&
(stripos($content, 'CMS') !== false)) ||