I got 2 templates for different product types. Each template has its own set of TVs describing that product’s attributes.
On a product page there’s a chunk that shows all of the product’s attributes.
So a PHx statement evaluates the template id and picks the correct TV for each attribute. Here’s the code:
[*phx:if=`[*template*]`:eq=`22`:then=`[[Ditto?&documents=`[*optionsTempRoof*]`&tpl=`@FILE:assets/chunks/templates/product_option_related_tpl.chk`]]`:else=`[[Ditto?&documents=`[*optionsPermRoof*]`&tpl=`@FILE:assets/chunks/templates/product_option_related_tpl.chk`]]`*]
The problem is that for every product only one TV exists. I would expect that in the example above PHx would evaluate from left to right and if the "eg=`22`" condition is true would output the value and stop. But it doesn’t. It continues to evaluate the statement in the "else" clause, finds the "optionsPerm2Roof" tv, and since it doesn’t exist throws this error:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[*optionsPermRoof*]) AND sc.published=1 AND sc.deleted=0) AND (' at line 3 »
SQL: SELECT DISTINCT sc.id FROM `smartspacedb`.`modx_site_content` sc LEFT JOIN `smartspacedb`.`modx_document_groups` dg on dg.document = sc.id WHERE (sc.id IN ([*optionsPermRoof*]) AND sc.published=1 AND sc.deleted=0) AND (sc.privateweb=0) GROUP BY sc.id
[Copy SQL to ClipBoard]
Parser timing
MySQL: 0.0100 s (14 Requests)
PHP: 0.1448 s
Total: 0.1548 s
If i change "optionsPermRoof" in the else clause to "optionsTempRoof", i.e. a TV that exists everything works fine. Is there a way to force PHx to stop evaluating after a true condition has been met?