sigil88
2/10/2017 - 5:02 PM

updated com_news featured news post / module for news section with strpos and strlen checks

updated com_news featured news post / module for news section with strpos and strlen checks

<?php foreach ( $list as $item) : 
		$postLink = $postsLink . '/' . $item->id . '-' . $item->alias;
		$fulltext	= strip_tags($item->fulltext, '<p><ul><li>');

		if ($item->featured == 1 and $featured <= $limitFeatured): ?>
			<div class="col-md-4">
				<div class="news__item">
					<div class="news__wrapper">
						<h4 class="news__title"><?php echo $item->title; ?></h4>
						<?php 
							$item->introtext ? $text = '<p>' . $item->introtext . '</p>' : $text = $fulltext; 
							
							if (strlen($text) > 300) : 
								echo substr(($text), 0, strpos($text, ' ', 300));
							else :
								echo $text;
							endif;

						?>
					</div>
					<a href="<?php echo $postLink; ?>" class="btn">READ MORE</a>
				</div>				
			</div>
		
			<?php $featured++; ?>
	<?php endif; 
		endforeach; 
	?>