Is it possible to multiple values of 2 fields

More
7 years 1 month ago - 7 years 1 month ago #70630 by erica
No it is not work.
My file "value_default_new.php" in folder "www\plugins\flexicontent_fields\text\tmpl"
Code:
<?php $n = 0; foreach ($values as $value) { // Skip empty value, adding an empty placeholder if field inside in field group if ( !strlen($value) ) { if ( $is_ingroup ) { $field->{$prop}[$n++] = ''; } continue; } // Add prefix / suffix //$field->{$prop}[$n] = $pretext . $value . $posttext; $field->{$prop}[$n] = $item->fieldvalues[48][$n] * $item->fieldvalues[49][$n]; // Add microdata to every value if field -- is -- in a field group if ($is_ingroup && $itemprop) $field->{$prop}[$n] = '<div style="display:inline" itemprop="'.$itemprop.'" >' .$field->{$prop}[$n]. '</div>'; $n++; if (!$multiple) break; // multiple values disabled, break out of the loop, not adding further values even if the exist }

I have a question. My fields belong to a fieldgroup. It's not a problem ? See my picture in attachment
Attachments:
Last edit: 7 years 1 month ago by ggppdk.

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

More
7 years 1 month ago - 7 years 1 month ago #70632 by ggppdk
Hello

the problem is that the field has no value in DB
so the display stops before loading your custom display layout

Do this
- set default value to: 0
- se vaue usage: ... and show default value instead of empty


-- 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: 7 years 1 month ago by ggppdk.

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

More
6 years 10 months ago #71918 by erica
Hello George,

I finally succeeded to multiplicate 2 fields in following your example :
www.flexicontent.org/forum/20-general-su...l?limitstart=0#70568 .
But I have a new issue : the result of the multiplication returns only one digit (the first digit).

Could you help me ?

Attachments:

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

More
6 years 10 months ago #71919 by ggppdk
Hello

it looks like you are getting the first character of a string using the operator

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

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

More
6 years 10 months ago #71921 by erica
Exactly, but how take all caracters.

My code is
Code:
$field1=$item->fields['field-1']->postdata; $field2=$item->fields['field-2']->postdata; $v = array(); foreach ($field1 as $i => $v) { $v[$i] = $field1[$i]*$field2[$i]; } return $v;

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

More
6 years 10 months ago - 6 years 10 months ago #72024 by ggppdk
Hello,

you are destroying the result variable
Code:
$v

The foreach line
Code:
$v = array(); foreach ($field1 as $i => $v)

must be
Code:
$v = array(); foreach ($field1 as $i => $IGNORED)

in my example it was $i => $p


-- 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 10 months ago by ggppdk.

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

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