How to get number of images in image gallery field?

More
5 years 9 months ago #73844 by lipatovroman

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


Yes, of course. I use correct field id:



And this code:
Code:
<?php $field_id = 20; $total_images = empty($item->fieldvalues[$field_id]) ? 0 : count($item->fieldvalues[$field_id]); ?> <h2><?php echo $total_images ?> Screenshots for <?php echo $item->fields["title"]->display;?></h2>

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

More
5 years 9 months ago #73845 by lipatovroman
Ok, I solved this problem differently.
I don't know is it correct, but it work )))
Code:
<?php $fvals = $item->fieldvalues[20]; foreach($fvals as $key) { $nc++; } ?> <h2><?php echo $nc ?> Screenshots for <?php echo $item->fields["title"]->display;?></h2>

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

More
5 years 9 months ago - 5 years 9 months ago #73847 by ggppdk
Hello

please note that
when images are zero the array does not exist
so if you enable error reporting you will see a list of variable undefined error

further more
if the code you wrote works , aka field id is 20 then use:
Code:
$nc = empty($item->fieldvalues[20]) ? 0 : count($item->fieldvalues[20]);


-- 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: 5 years 9 months ago by ggppdk.

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

More
5 years 9 months ago #73848 by lipatovroman
Thanks!
Need your help with another topics.

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

More
5 years 9 months ago #73849 by ggppdk
Hello

answering this topic only took 1 minute per answer ...


-- 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: 0.528 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