Skip to content

Commit

Permalink
Improve Related article style
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Aug 1, 2024
1 parent 221e7e8 commit e5a803d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions framework/frontend/blog/modules/related.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\Registry\Registry;
// No direct access.
defined('_JEXEC') or die;

Expand All @@ -25,16 +26,25 @@
<div class="relateditems row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4">
<?php foreach ($items as $item) : $images = json_decode($item->images);
$astroidArticle = new Astroid\Article($item, true);
// Post Format
$post_attribs = new Registry(json_decode($item->attribs));
$post_format = $post_attribs->get('post_format', 'standard');
$image = $astroidArticle->getImage();
?>
<div>
<div class="card">
<?php
// Generate media
if (!empty($images->image_intro)) {
echo '<img class="card-img-top" src="'.$images->image_intro.'" data-holder-rendered="true">';
} else if (is_string($image) && !empty($image)) {
echo '<div class="item-image">';
$document->include('blog.modules.image', ['image' => $image, 'title' => $item->title, 'item' => $item]);
echo '</div>';
} else {
echo LayoutHelper::render('joomla.content.post_formats.post_' . $post_format, array('params' => $post_attribs, 'item' => $item));
}
?>
<a href="<?php echo $item->route; ?>">
<img class="card-img-top" src="<?php echo $images->image_intro; ?>" data-holder-rendered="true">
</a>
<?php } ?>
<div class="card-body">
<h3 class="related-article-title">
<a href="<?php echo $item->route; ?>"><?php echo $item->title; ?></a>
Expand Down

0 comments on commit e5a803d

Please sign in to comment.