I'm trying to do some basic math using a Stash Get var and MX Calculator. Any recommendations? I'm sure my lack of understanding of parse order strikes again.
I can get the variable using:
{exp:stash:get name='house_starting_price'}
But when I try to use it in the MX_Calculator plugin the value doesn't parse.
{exp:mx_calc parse="inward" expression="({exp:stash:get name='house_starting_price'}*.05)"}
Based on feedback I've made the following adjustments:
The stash variable is set like so (note it is in a matrix field):
{exp:channel:entries channel="Homes" dynamic="no" limit="1" url_title="{segment_3}" require_entry="yes" disable="categories|category_fields|member_data|pagination"}
{!-- Go through the elevations matrix but only pull the fields that are from the current community, set with segment_4 --}
{elevations orderby="elevation_name" sort="asc" orderby="elevation_name" sort="asc" search:elevation_community="{segment_4}"}
{!-- Stash the first price as starting price for community --}
{exp:stash:set name="house_starting_price" match="^1$" against="{row_count}"}{elevation_price thousands_sep=''}{/exp:stash:set}
{/elevations}
{/exp:channel:entries}
I've modified the stash get to use stash:parse:
<br>starting price = {exp:stash:get name='house_starting_price'}
{exp:stash:parse parse="end"}<br>This is within stash parse: {exp:stash:house_starting_price}
<br>MX Calculator value: {exp:mx_calc expression="({exp:stash:house_starting_price}*.05"})
{/exp:stash:parse}
Here's what's output:
Starting price = 326600
This is within stash parse: 326600
MX Calculator value:
In the output debugger I see:
{exp:mx_calc expression="(M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr*.05"})
{exp:mx_calc expression="(365000*.05)"} <-manually entered 365000
UPDATE 2012-12-01
I've simplified this even more for testing. This takes channel:entries out of the equation all together. I'm finally getting it to calculate but I'm seeing some weird stuff.
{!-- Set the mytestvariable --}
{exp:stash:set name="mytestvariable"}645323{/exp:stash:set}
<br>The test variable outside of MX Calculator equals: {exp:stash:get name="mytestvariable"}
{!-- Use stash:parse to attempt using the stash var within MX Calculator --}
{exp:stash:parse process="end"}
{!-- Ensure the varible loads within stash:parse --}
<br>The test variable within Stash Parse equals: {exp:stash:get name="mytestvariable"}
{!-- Try to use the stash variable in MX Calculator --}
<br>The test varible within MX Calculator equals: {exp:mx_calc parse="inward" expression="{exp:stash:get name='mytestvariable'}*.05"}
{/exp:stash:parse}
Output:
The test variable outside of MX Calculator equals: 645323
The test variable within Stash Parse equals: M60o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr
The test varible within MX Calculator equals: 32266.15
Question: Should the second value not equal 645323?
Note: I tried switching all stash gets to shorthand version as well: {exp:stash:mytestvariable}
When I do this I get the following output:
The test variable outside of MX Calculator equals: 645323
The test variable within Stash Parse equals: 32266.15
The test varible within MX Calculator equals:
When I look in the debugger MX Calc is using M60o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr*.05 instead.