I need to choose which documents to include in a Ditto call based on a value of a TV. I’ve tried many different variations on the theme but keep getting SQL errors.
The basic Ditto call works just fine:
[[Ditto?documents=`[*optionsTempRoof*]` &tpl=`@FILE:assets/chunks/templates/product_option_related_tpl.chk` ]]
Then i turned off the built-in PHx and tried the conditional statement like so:
[[Ditto?documents=`[*phx:input=`[*optionsTempRoof*]`:len:gt=`0`:then=`[*optionsTempRoof*]`:else=`[*optionsPermRoof*]`*]` &phx=`0` &tpl=`@FILE:assets/chunks/templates/product_option_related_tpl.chk` ]]
which resulted in the following error message:
« 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 '[*phx:inpu) AND sc.published=1 AND sc.deleted=0) AND (sc.privat' 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 ([*phx:inpu) AND sc.published=1 AND sc.deleted=0) AND (sc.privateweb=0) GROUP BY sc.id
At first i thought it was my syntax of the PHx statement but then just for the test i tried a simple PHx modifier like so:
[[Ditto?&documents=`[*phx:input=`[*optionsTempRoof*]`:math=`?+1-1`*]`&phx=`0`&tpl=`@FILE:assets/chunks/templates/product_option_related_tpl.chk`]]
and got 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 '[*phx:inpu) AND sc.published=1 AND sc.deleted=0) AND (sc.privat' 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 ([*phx:inpu) AND sc.published=1 AND sc.deleted=0) AND (sc.privateweb=0) GROUP BY sc.id
Which tells me that PHx is not getting parsed inside Ditto. Running the same PHx statement by itself returns the the correct document id.
Any suggestions will be greatly appreciated.
Thanks in advance.