we are using the {{depend}} functionality to check for true on a system config variable
But now we are running into the following. Can I combine these special {{}} tags within each other? For example if I want to check config path='some/value/here' to be TRUE, would I do it as follows?
{{depend {{config path='some/value/here'}}}} text here
Question: How can I use the depend to check a config path value?
And maybe a second question is: does depend check for empty, or does it also understand yes and no's from the config?
Many thanks
Best Answer
You cannot use
{{depend}}
and{{config}}
in that combination for 2 reasons.The first and most important is that the regex match is screwed up like this. If you have a text like this
{{depend name}} some text {{/depend}}
the matches array looks like this:This means that if the value for the variable
name
evaluates to something else thannull
false
0
the value in [0] (the expression) will be replaced with the value from [2] (some text).If you try it with
{{depend {{config path="some/path/here"}}}} some text {{/depend}}
the matches look like this:The second reason is that the depend conditions must be a variable passed to the template (element inside the
_templateVars
member).The work around for this is to pass the value from the config as a variable to the template and then use that variable in the
depend
statement.Let's take for example the new order e-mail sending. In
Mage_Sales_Model_Order::sendNewOrderEmail()
Turn it into this:
Now you should be able to use: