Rules: validate uid of pagetemplate
Author: sharzmeier
Publication Date: 5/5/2023 15:48
Hi.
is there a way to check inside the rules of a section tempate, if the uid of the pagetemplate in use equals to some string?
Below a non working example, like I would excpect it to be.
<RULE> <IF> <EQUAL> <PROPERTY name="value" source="#global.page.template.uid"/> <TEXT>homepage</TEXT> </EQUAL> </IF> <WITH> <FALSE/> </WITH> <DO> <PROPERTY name="VISIBLE" source="#form.target_group"/> </DO> </RULE>
-
Author: hoebbel - 5/12/2023 14:08
Hi sharzmeier,
you could try this:
Define a (hidden) text component within the (all) pagetemplates, which saves the template UID, e.g.
<CMS_INPUT_TEXT name="pt_templateuid" hidden="no"> <LANGINFOS> <LANGINFO lang="*" label="templateuid"/> </LANGINFOS> </CMS_INPUT_TEXT> <RULE when="ONLOCK"> <WITH> <PROPERTY name="TEMPLATE" source="#global"/> </WITH> <DO> <PROPERTY name="VALUE" source="test"/> </DO> </RULE>Now you can use the FormDataValueService to copy this information to an appropriate (hidden) component within the section template
<CMS_INPUT_TEXT name="st_pagetemplate_uid" hidden="no"> <LANGINFOS> <LANGINFO lang="*" label="pagetemplate uid"/> </LANGINFOS> </CMS_INPUT_TEXT> <RULE> <SCHEDULE delay="0" id="pagetemplate" service="FormDataValueService"> <PARAM name="UID"> <PROPERTY name="PAGE_UID" source="#global"/> </PARAM> <PARAM name="UIDTYPE"> <TEXT>PAGESTORE</TEXT> </PARAM> <PARAM name="FIELD"> <TEXT>pt_templateuid</TEXT> </PARAM> <PARAM name="LANGUAGE"> <TEXT>DE</TEXT> </PARAM> </SCHEDULE> <DO> <PROPERTY name="VALUE" source="st_pagetemplate_uid"/> </DO> </RULE>Now you can use the content of this component within your rule
Best regards
HolgerHint: This will only work for changed pages. The formDataValueService reads the stored information. So the page has to be saved once with the pagetemplate information - afterwards it will be available within the section template
0 -
Author: sharzmeier - 5/15/2023 15:31
tricky, but it works
0 -
Author: matthiasforberg - 10/18/2024 10:50
Thanks! Very helpful!
0
Please sign in to leave a comment.
Comments
3 comments