Calculation using Plotalot sql shortcodes

dewebkrant

New Member
Unfortunately, this does not seem to work out of the box although logically it should I think:
$dienstena='{plotalot id="37"}';
$dienstenb='{plotalot id="36"}';
$totalBTW=$dienstena-$dienstenb;
return $totalBTW;
But totalBTW is showing 0 while
return '{plotalot id="37"}'; shows 1328 and
return '{plotalot id="36"}'; shows 1108
It is about: http://boekhouden.samuelservices.nl/nl/btw-aangifte-demo
Someone an idea?
 
I "solved" this by using the calc element solution proposed by Nick on http://fabrikar.com/forums/index.ph...n-for-sum-total-in-element.44417/#post-228180 - instead of a sql query from Plotalot, I placed the $db strings in the elements used for calculating $dienstena-$dienstenb and now I get the outcome as needed but I am still interested in a solution of how to use Plotalot shortcodes in calculations. I managed to use 1 plotalot shortcode in 1 calc element but combining 2 in a calculation does not work sofar....
 
Maybe the plotalot string is not replaced in the calc but afterwards.
You can test by adding e.g. var_dump($dienstena);exit;
 
Ok thanks @troester but can you please explain how I can test this and where to add var_dump($dienstena);exit; ? I tried by putting this code in the calc element where I use $dienstena-$dienstenb; with the plotalot shortcodes as described but outcome is still 0 - And if "Maybe the plotalot string is not replaced in the calc but afterwards." what can be done to repair this?
Thanks
 
Put it in the calc before the return. It should display an empty site with just the dump info.
what can be done to repair this
I don't know if you can.
Try "Process Joomla plugins" in form "Options" (but I think this is not working for inside calc code).
 
Doing that multiple plotalot thing won't work that way because content plugins don't return a value, they echo (render) content. So you can't assign their "output" with an =. You might be able to capture the output buffer. I'll take a look when I get home, am at the airport atm.

Sent from my HTC6545LVW using Tapatalk
 
OK, try this:

Code:
$dienstena='{plotalot id="37"}';
FabrikHelperHTML::runContentPlugins($dienstena);
$dienstenb='{plotalot id="36"}';
FabrikHelperHTML::runContentPlugins($dienstenb);
$totalBTW = (int)$dienstena - (int)$dienstenb;
return $totalBTW;

That uses our built in helper function to run the plugin and return the result.

-- hugh
 
Thanks for the FabrikHelperHTML::runContentPlugins hint - that helps to return a value in the details view instead of the shortcode so I guess the outcome can be used in the calculations element also.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top