Php condition based on the number of values of a field

More
9 years 11 months ago #55908 by bendeb
Hello,

I have a question about Flexicontent templating (I use FC 3.0 RC on Joomla 3.4).

I call my fields in item.php with this syntax :
Code:
<?php echo $this->fields['my_field']->display; ?>
my_field is configured to allow mutliple values.
So if I put three values (value1, value2 and value3) my template also display the three values in my item (obviously :lol: ).

But now, I want to call an additionnal css file (without create another FC template, I have already think about that but it's not convenient for me) based on the number of values "my_field" has.
  • If "my_field" have multiple values, it use the normal item.css.
  • But if "my_field" have only one value, I want to call an additionnal css file.

How can I do this in my template ? What sort of syntax (specific to FC I think) permit that ?

Many thank for your answer. :)

Bye.

Flexicontent 4.1.0b1
Joomla 3.9.18

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

More
9 years 11 months ago - 9 years 11 months ago #55910 by ggppdk
Hello

read this FAQ article:
Using the raw value of a field inside a template file or inside a new custom field type

then use:
Code:
$value_count = is_array($fvals) ? count($fvals) : 0;


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

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

More
9 years 11 months ago #55951 by bendeb
Hello ggppdk, thank for your reply. :)

I tried your given method but I didn't manage to make it work. My php knowledges are very limited.

However, I found another solution to do approximatively what I want.
It's not exactly what I wanted, but that's fine in the first time. I'll try to implement your method later when I understand what to do.

Thank for your help :)

Flexicontent 4.1.0b1
Joomla 3.9.18

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.728 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