Multiplying two fields together

More
7 years 9 months ago #63245 by dan40
Hi, I want to create a SUM field, and enter a multiplication parameter to work out the total of all values in that field, across all of my articles. The parameters are Quantity (field20) times Value (field23). It would have to be something like:

$sum(field20*field23)

Is this possible? Where do I enter the parameter? And before anyone says anything, I looked in the docs and the forum and cannot find an answer. Thanks to anyone who can help!

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

More
7 years 9 months ago #63249 by micker
sorry its not possible now (we planne it) you can only do it in template view
with php

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
7 years 8 months ago - 7 years 8 months ago #63285 by ggppdk
Hello

e.g. fields no 45 and field no 46

- create a custom VIEW layout file

copy file:
flexicontent_fields/text/tmpl/value_default.php
to:
flexicontent_fields/text/tmpl/value_multiply_45_46.php

and edit to customize the display , remove ALL contents and add:
Code:
<?php $value = $item->fieldvalues[45][0] * $item->fieldvalues[46][0]; $field->{$prop}[0] = $value;

or to make it more complete:
Code:
<?php $n = 0; foreach ($values as $value) { if ( !strlen($value) && !$is_ingroup ) continue; // Skip empty if not in field group if ( !strlen($value) ) { $field->{$prop}[$n++] = ''; continue; } // Add prefix / suffix $value = $item->fieldvalues[45][0] * $item->fieldvalues[46][0]; $field->{$prop}[$n] = $pretext . $value . $posttext; // 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 }


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

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

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