Created
March 4, 2022 07:22
-
-
Save drmenzelit/77d86e11b041ec6fa9394da139dd76fc to your computer and use it in GitHub Desktop.
Fulltext image on module override (example with mod_articles_latest)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @package Joomla.Site | |
| * @subpackage mod_articles_latest | |
| * | |
| * @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\Layout\LayoutHelper; | |
| if (!$list) | |
| { | |
| return; | |
| } | |
| ?> | |
| <ul class="mod-articleslatest latestnews mod-list"> | |
| <?php foreach ($list as $item) : ?> | |
| <?php | |
| $images = json_decode($item->images); | |
| $item->imageSrc = ''; | |
| $item->imageAlt = ''; | |
| $item->imageCaption = ''; | |
| $item->imageSrc = htmlspecialchars($images->image_fulltext, ENT_COMPAT, 'UTF-8'); | |
| $item->imageAlt = htmlspecialchars($images->image_fulltext_alt, ENT_COMPAT, 'UTF-8'); | |
| if ($images->image_intro_caption) | |
| { | |
| $item->imageCaption = htmlspecialchars($images->image_fulltext_caption, ENT_COMPAT, 'UTF-8'); | |
| } | |
| ?> | |
| <li itemscope itemtype="https://schema.org/Article"> | |
| <a href="<?php echo $item->link; ?>" itemprop="url"> | |
| <span itemprop="name"> | |
| <?php echo $item->title; ?> | |
| </span> | |
| <figure class="newsflash-image"> | |
| <?php echo LayoutHelper::render( | |
| 'joomla.html.image', | |
| [ | |
| 'src' => $item->imageSrc, | |
| 'alt' => $item->imageAlt, | |
| ] | |
| ); ?> | |
| <?php if (!empty($item->imageCaption)) : ?> | |
| <figcaption> | |
| <?php echo $item->imageCaption; ?> | |
| </figcaption> | |
| <?php endif; ?> | |
| </figure> | |
| </a> | |
| </li> | |
| <?php endforeach; ?> | |
| </ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment