This Joomla 4 override allows you to display the articles from a feed RSS simply using Joomla's mod_feeds module. At the bottom of this article, you can download the files of the override.

Joomla 4 frontend rendering

PhP markup

<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_feed
 * @author		web-eau.net
 * @copyright   (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

// Check if feed URL has been set
if (empty ($rssurl))
{
	echo '<div>' . Text::_('MOD_FEED_ERR_NO_URL') . '</div>';

	return;
}

if (!empty($feed) && is_string($feed))
{
	echo $feed;
}
else
{
	$lang      = $app->getLanguage();
	$myrtl     = $params->get('rssrtl', 0);
	$direction = ' ';

	$isRtl = $lang->isRtl();

	if ($isRtl && $myrtl == 0)
	{
		$direction = ' redirect-rtl';
	}

	// Feed description
	elseif ($isRtl && $myrtl == 1)
	{
		$direction = ' redirect-ltr';
	}

	elseif ($isRtl && $myrtl == 2)
	{
		$direction = ' redirect-rtl';
	}

	elseif ($myrtl == 0)
	{
		$direction = ' redirect-ltr';
	}
	elseif ($myrtl == 1)
	{
		$direction = ' redirect-ltr';
	}
	elseif ($myrtl == 2)
	{
		$direction = ' redirect-rtl';
	}

	if ($feed !== false)
	{
		?>
		<div style="direction: <?php echo $rssrtl ? 'rtl' :'ltr'; ?>;" class="text-<?php echo $rssrtl ? 'right' : 'left'; ?> feed">
		<?php
		// Feed title
		if ($feed->title !== null && $params->get('rsstitle', 1))
		{
			?>
				<h2 class="text-center display-4 <?php echo $direction; ?>">
					<a href="<?php echo htmlspecialchars($rssurl, ENT_COMPAT, 'UTF-8'); ?>" target="_blank" rel="noopener">
					<?php echo $feed->title; ?></a>
				</h2>
			<?php
		}
		// Feed date
		if ($params->get('rssdate', 1)) : ?>
        	<h3>
			<?php echo HTMLHelper::_('date', $feed->publishedDate, Text::_('DATE_FORMAT_LC3')); ?>
			</h3>
          </div>
		<?php endif;
		// Feed description
		if ($params->get('rssdesc', 1))
		{
		?>	 <div class="text-center fs-6 pb-5">
			<?php echo $feed->description; ?>
			</div>
			<?php
		}
		// Feed image
		if ($feed->image && $params->get('rssimage', 1)) :
		?>
		<img src="<?php echo $feed->image->uri; ?>" alt="<?php echo $feed->image->title; ?>" class="" />
		<?php endif; ?>


	<!-- Show items -->
	<?php if (!empty($feed))
	{ ?>
		<div class="row row-cols-1 row-cols-md-3 g-4 newsfeed"> <!-- because we want 3 items per row -->
		<?php for ($i = 0, $max = min(count($feed), $params->get('rssitems', 3)); $i < $max; $i++) { ?>
			<?php
				$uri  = $feed[$i]->uri || !$feed[$i]->isPermaLink ? trim($feed[$i]->uri) : trim($feed[$i]->guid);
				$uri  = !$uri || stripos($uri, 'http') !== 0 ? $rssurl : $uri;
				$text = $feed[$i]->content !== '' ? trim($feed[$i]->content) : '';
			?>
				<div class="col">
                  <div class="border rounded py-2 h-100">
                   
					<?php if (!empty($uri)) : ?>
						<div class="fs-4 fw-bold feed-link px-2">
						<a href="<?php echo htmlspecialchars($uri, ENT_COMPAT, 'UTF-8'); ?>" target="_blank" rel="noopener">
						<?php echo trim($feed[$i]->title); ?></a></div>
					<?php else : ?>
						<div class="feed-link"><?php echo trim($feed[$i]->title); ?></div>
					<?php endif; ?>

					<?php if ($params->get('rssitemdate', 0)) : ?>
						<div class="feed-item-date pb-3 ps-2 small fst-italic">
							<?php echo HTMLHelper::_('date', $feed[$i]->publishedDate, Text::_('DATE_FORMAT_LC3')); ?>
						</div>
					<?php endif; ?>

					<?php if ($params->get('rssitemdesc', 1) && $text !== '') : ?>
						<div class="feed-item-description">
						<?php
							//Strip the images.
							//$text = OutputFilter::stripImages($text);
							$text = HTMLHelper::_('string.truncate', $text, $params->get('word_count', 0));
							echo str_replace('&apos;', "'", $text);
						?>
						</div>
					<?php endif; ?>
				</div>
          	</div>
		<?php } ?>
		</div>
	<?php } ?>
	</div>
	<?php }
 
}

CSS

div.feed-item-description > p {font-size:14px !important;padding-left: 10px !important;}
 

This Joomla 3 override allows you to display the articles from a feed RSS simply using Joomla's mod_feeds module. At the bottom of this article, you can download the files of the override.

Joomla 3 frontend rendering

PhP markup

<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_feed
 * @Author 		web-eau.net
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;
?>

<?php
if (!empty($feed) && is_string($feed))
{
	echo $feed;
}
else
{
	$lang      = JFactory::getLanguage();
	$myrtl     = $params->get('rssrtl', 0);
	$direction = ' ';

	$isRtl = $lang->isRtl();

	if ($isRtl && $myrtl == 0)
	{
		$direction = ' redirect-rtl';
	}

	// Feed description
	elseif ($isRtl && $myrtl == 1)
	{
		$direction = ' redirect-ltr';
	}

	elseif ($isRtl && $myrtl == 2)
	{
		$direction = ' redirect-rtl';
	}

	elseif ($myrtl == 0)
	{
		$direction = ' redirect-ltr';
	}
	elseif ($myrtl == 1)
	{
		$direction = ' redirect-ltr';
	}
	elseif ($myrtl == 2)
	{
		$direction = ' redirect-rtl';
	}

	if ($feed !== false)
	{
		// Image handling
		$iUrl   = isset($feed->image) ? $feed->image : null;
		$iTitle = isset($feed->imagetitle) ? $feed->imagetitle : null;
		?>
		<div style="direction: {{{PHP3}}}; text-align: {{{PHP4}}} !important" class="feed<?php echo $moduleclass_sfx; ?>">
		<?php
          
		// Feed title
		if ($feed->title !== null && $params->get('rsstitle', 1))
		{
			?>
			<h2 class="text-center text-primary display-4 <?php echo $direction; ?>">
			<a href="/<?php echo htmlspecialchars($rssurl, ENT_COMPAT, 'UTF-8'); ?>" target="_blank">
			<?php echo $feed->title; ?></a>
			</h2>
			<?php
		}
      
		// Feed date
		if ($params->get('rssdate', 1)) : ?>
			<h3>
			<?php echo JHtml::_('date', $feed->publishedDate, JText::_('DATE_FORMAT_LC3')); ?>
			</h3>
		<?php endif;
      
		// Feed description
		if ($params->get('rssdesc', 1))
		{
		?>
			<h5 class="text-center text-primary">
            <?php echo $feed->description; ?>
            </h5>
			<?php
		}
      
		// Feed image
		if ($iUrl && $params->get('rssimage', 1)) :
		?>
			<img src="/<?php echo $iUrl; ?>" alt="<?php echo @$iTitle; ?>" />
		<?php endif; ?>
		
          <hr />

	<!-- Show items -->
	<?php if (!empty($feed))
	{ ?>
		<div class="mx-auto w-50 py-3 newsfeed<?php echo $params->get('moduleclass_sfx'); ?>">
      	<a href="/<?php echo htmlspecialchars($rssurl, ENT_COMPAT, 'UTF-8'); ?>" target="_blank">
		<?php for ($i = 0, $max = min(count($feed), $params->get('rssitems', 3)); $i < $max; $i++) { ?>
			<?php
				$uri  = $feed[$i]->uri || !$feed[$i]->isPermaLink ? trim($feed[$i]->uri) : trim($feed[$i]->guid);
				$uri  = !$uri || stripos($uri, 'http') !== 0 ? $rssurl : $uri;
				$text = $feed[$i]->content !== '' ? trim($feed[$i]->content) : '';
			?>
              
				<div class="">
					
              		<?php if (!empty($uri)) : ?>                      
						<div class="card-title feed-link px-2">
						<h5><a href="/<?php echo htmlspecialchars($uri, ENT_COMPAT, 'UTF-8'); ?>" target="_blank">
						<?php echo trim($feed[$i]->title); ?></a> <small class="text-muted">(<?php echo JHtml::_('date', $feed[$i]->publishedDate, JText::_('DATE_FORMAT_LC3')); ?>)</small>
                        </h5>
                        </div>    
					<?php else : ?>
						<div class="feed-link"><?php echo trim($feed[$i]->title); ?></div>
					<?php endif; ?>
                      
					<?php if ($params->get('rssitemdate', 0)) : ?>
						<div class="feed-item-date">
							<?php echo JHtml::_('date', $feed[$i]->publishedDate, JText::_('DATE_FORMAT_LC3')); ?>
						</div>
					<?php endif; ?>
                      
					<?php if ($params->get('rssitemdesc', 1) && $text !== '') : ?>
						<div class="px-2 feed-item-description">
						<p class="px-2"><?php
							// Strip the images.
							//$text = JFilterOutput::stripImages($text);
							$text = JHtml::_('string.truncate', $text, $params->get('word_count', 0));
							echo str_replace('&apos;', "'", $text);
						?></p>                         
                        </div>
					<?php endif; ?>
                   
				</div>
		<?php } ?>
          </a>
		</div>
	<?php } ?>
	</div>
	<?php }
}
 

web-eau.net

29800 Landerneau

+33 674 502 799

daniel@web-eau.net