Page tree
Skip to end of metadata
Go to start of metadata

There will be lots of cases where you'll not want to render code if your users who are filling out your content type leaves a field blank. This would be a perfect scenerio to use "selective output."

Imagine you have a field in your content type called "Heading-3." Your regular T4 tag for this content type is:

<t4 type="content" name="Heading-3" output="normal" modifiers=""  />

This tag rendered out with content in it as "My name is Sam" and a version of the field left blank would be:

<!-- field filled out, okay -->
My name is Sam.
<!-- field left blank -->
[nothing, which is fine]

But say for a minute you wanted to surround this in <h3> tags, you would have to do something like:

<h3><t4 type="content" name="Heading-3" output="normal" modifiers=""  /></h3>

and this would render

<!-- field filled out, okay -->
<h3>My name is Sam.</h3>
<!-- field left blank, you have empty h3 tags for no reason -->
<h3></h3>

Here is where selective output gets put to use. You can change output="normal" to output="selective-output, add process-format="true" (saying the field is filled out)(I do not believe process-format="false" works) and add a format="[whatever you want]". Back to our scenario, our new selective output tag looks like:

<t4 type="content" name="Heading-3" output="selective-output" process-format="true" modifiers="" format="<h3>Here is where I'll put my name</h3>" />

Would render:

<!-- field filled out, okay -->
<h3>Here is where I'll put my name</h3>
<!-- field left blank, nothing gets rendered -->
 

Obviously in the last example we've hardcoded "Where is where I'll put my name", but we want our user to be able to add their own name in the content type.  There are two ways to achieve this:

<!-- using $value outputs the field value -->
<t4 type="content" name="Heading-3" output="selective-output" process-format="true" modifiers="" format="<h3>$value</h3>" />
 
<!-- T4 tag inside T4 tag -->
<t4 type="content" name="Heading-3" output="selective-output" process-format="true" modifiers="" format="<h3><t4 type=&quot;content&quot; name=&quot;Heading-3&quot; output=&quot;normal&quot; modifiers=&quot;&quot; /></h3>" />

would render:

<!-- using $value outputs the field value -->
<h3>My name is Sam.</h3>
<!-- T4 tag inside T4 tag -->
<h3>My name is Sam.</h3> 

Note: If you use the content type inside of a content type you'll have to remember to use the HTML equivalents for any code inside the original t4 tag. Most of the time this means you'll have to replace all " with &quot; in the inside tag.

 

 

 

 

 

<t4 type="content" name="Heading-3" output="selective-output" process-format="true" modifiers="" format="<h3>$value</h3>" />
<t4 type="content" name="Heading-3" output="selective-output" process-format="true" modifiers="" format="<t4 type=&quot;content&quot; name=&quot;Heading-3&quot; output=&quot;normal&quot; modifiers=&quot;&quot;  />" />
  • No labels