I seem to be a bind. I have this code below

foreach ($items as $item)

        search:field_name="<?php echo $item['some_key']; ?>"
        {if no_results}
                $price = number_format( floatval("{some_cost}") + floatval("{some_margin}"), 1);
                echo $price;

As you can see, I need to pass the value of a PHP variable into the channel entries tag. For this case, we want PHP to parse early, before EE tags. So that means PHP parsing stage should be set to "input"

But I also need to get the values of the EE tags inside the channel entries and compute them in PHP. However, that means that we want PHP to parse late, after EE tags are parsed. That could be done if PHP parsing stage should be set to "output"

Obviously, I can't set PHP parsing stage to both values.

Is there a way around this problem?

1 Answer 1


Do this right way - do not follow the dark side.

Put all your php code into plugin. Your code is not good even from optimization way - not good solution to loop the channel entry. Just make function which will return list of


In this case you will do only one request of channel:entry. For calculation

$price = number_format( floatval("{some_cost}") + floatval("{some_margin}"), 1);

make one more function or use exist plugin (like MX Calculator);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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