[Solved] How to get field's value count

More
10 years 11 months ago - 10 years 11 months ago #48340 by kath
hi there,

let's say i have an image field with zero to six possible values. To find out how many images my item actually has, i currently do this in my template using php:

$i_img_count = count($this->fields->thumbs_path);

This works, but is there a more elegant way i have missed?

Thanks! :)
Last edit: 10 years 11 months ago by kath.

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

More
10 years 11 months ago #48347 by ggppdk
Hello

there is no problem using this
but it requires that the field's HTML has been created (=rendered)

the way to do , regardless if the field 's HTML has been created is to use:
Code:
$field_id = 55; // set the field id here echo count( $item->fieldvalues[$field_id] );

about raw field value array:

Using the raw value of a field inside a template file or inside a new custom field type


-- 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.

More
10 years 11 months ago #48358 by kath
great, thanks!

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.316 seconds
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
Save