0

I use this code using exp:math plugin:

{exp:channel:entries channel="planilla_de_indicadores" limit="10"}

{exp:math formula="([1] / [2]) * 100" parse="inward" params="{ps_talleres2}|{ps_talleres1}" decimals="2" absolute="yes"}

{/exp:channel:entries}

Here are the results:

ps_talleres1: 50 | ps_talleres2: 200 | Result: 25

The problem is i need to use the result in a conditional like this:

{if {exp:math formula="([1] / [2]) * 100" parse="inward" params="{ps_talleres2}|{ps_talleres1}" decimals="2" absolute="yes"} >= "50"}

<span class="badge badge-warning">
{exp:math formula="([1] / [2]) * 100" parse="inward" params="{ps_talleres2}|{ps_talleres1}" decimals="2" absolute="yes"}%
</span>

{/if}

As expected; it doesn't work as plugin and tmp parsing order. After some google i think maybe "Pre-embed" or "stash" might help... I saw a few answers pointing to "turn plugin into a tag pair" but not sure how.

2
  • Doesn't work why? What's happening? I'm asking because maybe the random parameter on one of the plugin tags can help. – Sobral Jul 17 '14 at 21:49
  • Thanks @robson ... Actually it's now working, can't say why... I will share – Martin Pede Jul 18 '14 at 21:38
1

Working

    {html_open}
    {html_head_end}
    {html_body}

    {embed="app_includes/header"}
     {contentpanel_open}

{exp:channel:entries channel="planilla_de_indicadores" limit="100"}

{if {exp:math formula="([1] / [2]) * 100" parse="inward" params="{ps_talleres2}|{ps_talleres1}" decimals="2" absolute="yes"} >= "50"}
    <span class="badge badge-warning">
    {exp:math formula="([1] / [2]) * 100" parse="inward" params="{ps_talleres2}|{ps_talleres1}" decimals="2" absolute="yes"}% {title}<br />
    </span>
{/if}

{if {exp:math formula="([1] / [2]) * 100" parse="inward" params="{ps_talleres2}|{ps_talleres1}" decimals="2" absolute="yes"} <= "49"}
    <span class="badge badge-danger">
    {exp:math formula="([1] / [2]) * 100" parse="inward" params="{ps_talleres2}|{ps_talleres1}" decimals="2" absolute="yes"}% {title}<br />
    </span>
{/if}

{/exp:channel:entries}

    {contentpanel_close}
    {embed="app_includes/rightpanel"}

    <!-- define custom page js (if) -->
    {html_close}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.