#1170 Posted in ‘Showtime Image Gallery’

Latest post by Lefteris Kavadas on Tuesday, 27 February 2024 11:11 EET

Yannick Lämmel
Hi Lefteris,

I have another question. With Joomla 3 we used Helix Ultimate Template and its Article Gallery function and were able to get the first image of the gallery in the category blog layout. So we could display it next to the text.

This was really cool because our customer can create the articles by himself and the image in the category does not have to be selected or uploaded into the article intro image.

I was trying to reach this with your plugin (plugin_showtime_fields). I made an override for the carousel layout that is correctly displayed in the article details. But if I try to get the first picture in the category block by "$this->item->jcfields['ID of the field'], there the value is the whole gallery like in my carousel override and the rawvalue is just the ID of the gallery.

I am able to get the image path, when I put a span with a class and two special glyphs at the beginning of the override, like this:
echo '<span class="first-image">♥'.$gallery->images[0]->preview.'♥</span>';
Then I can explode the value of the custom fiels at the ♥ and have the correct path to the image. But then the span is also at the article details page where I have to hide it with CSS. I am not that happy with this solution.

Can you think of a more clever way how I can get the single images paths? Or maybe just the first, that would be sufficient.

Kind regards,
Tanja

Lefteris Kavadas
Hi Tanja,

Probably I am not getting something. As you wrote, the first image data is available in the array:
$gallery->images[0]


What's the extra data you need?

If you have only the ID then you can get the gallery data using the code below:
require_once JPATH_ADMINISTRATOR . '/components/com_showtime/helpers/showtime.php';
$gallery = ShowtimeHelper::gallery($galleryId);


If you want to have different output on your layout based on the view then you can use something like this:
use Joomla\CMS\Factory;
$app   = Factory::getApplication();
$input = $app->getInput();
$view = $input->getCmd('view');
if($view === 'article') {

} else {

}


Regards

Yannick Lämmel
Hi Lefteris,

The one with the showtime helper is exactly what I need.

Until now I had to create this invisible span in the field layout file and there integrate the $gallery->images[0] so that in my category blog I could exploade this span.

But with this solution I can get the values without creating this span and get the data of the gallery in the category blog layout file.

Thank you very much, this really helps!

Kind regards,
Tanja

Lefteris Kavadas
You are welcome.

Note: An active subscription is required in order to get support for our paid extensions. For our free extensions, if you don't have an account, register and then submit your support request.  In case you just want to ask a question, you can also use the contact form .

Firecoders
Are you using our extensions? Please post a review at the Joomla extensions directory!
Post a review