How to get number of images in image gallery field?

More
6 years 6 months ago #73815 by lipatovroman
Hello!
I need to display how much images contains image field.
Something like this: Total 12 images in this gallery.
How I can get this variable in item view template?
Thanks.

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago - 6 years 6 months ago #73825 by ggppdk
Hello

you want to do it manually
Code:
$field_id = 57; $total_images = empty($item->fieldvalues[[$field_id]) ? 0 : count($item->fieldvalues[$field_id]);

But you can also enable display of total number of images in field's configuration


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 6 years 6 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago #73829 by lipatovroman

ggppdk wrote: Hello

you want to do it manually

Code:
$field_id = 57; $total_images = empty($item->fieldvalues[[$field_id]) ? 0 : count($item->fieldvalues[$field_id]);

But you can also enable display of total number of images in field's configuration


Hello!

When I added this code page not opens - it display error 500

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago - 6 years 6 months ago #73833 by ggppdk
If you enabled Debug
you will be notified of the syntax error
Code:
empty($item->fieldvalues[[$field_id])
correct [[ to be [
so it should be
Code:
empty($item->fieldvalues[$field_id])


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 6 years 6 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago #73836 by lipatovroman
Fixed.
But now $total_images always = 0, so it displays 0;

Please Log in or Create an account to join the conversation.

More
6 years 6 months ago #73843 by ggppdk
Hello

you will need to use a correct field id
in my example it was
$field_id = 57;


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 1.902 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline