sharzmeier
New Creator

Rules: validate uid of pagetemplate

Jump to solution

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>

 

 

 

0 Kudos
1 Solution

Accepted Solutions
hoebbel
Crownpeak employee

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
Holger

Hint: 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

View solution in original post

0 Kudos
3 Replies
hoebbel
Crownpeak employee

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
Holger

Hint: 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 Kudos

tricky, but it works 🙂

0 Kudos
matthiasforberg
Occasional Collector
0 Kudos