Understanding the Textpattern `yield` tag


Textpattern CMS structural tags help with the overall content structure of the site, and can be used to automate the presentation of material to the browser. In my previous article, I explained about the delightfully-simple `output_form` tag, along with a couple of examples of how to use it. For my fifth and final piece about structural tags, the subject is the Textpattern `yield` tag.

It essentially transforms `output_form` from a single tag into a container tag, and the `yield` part will return the contents of the container. Here’s a reminder of how `output_form` does its thing in its guise as a single tag:

<txp:output_form name="information" />

Simply, it processes the form given and outputs it to the browser where appropriate. Now, `yield` comes into play when `output_form` becomes a container tag. Consider this form referenced above — information — and it has the following (deliberately simple) content:

This is static content in the miscellaneous form called 'information'.
<txp:yield />

The magic with `yield` happens when the single tag becomes a container, like this:

<txp:output_form name="information" />
…and this text is what's inside the container tag.

The output will be:

This is static content in the miscellaneous form called 'information'. …and this text is what's inside the container tag.

I’ve known about this tag since its introduction 5+ years ago. It’s a tag I’ve never had to use on a production website, but one that might tick a box for you.

Looking for quality Textpattern Hosting? Look no further than Arvixe Web Hosting and use coupon TEXTPATTERN for 20% off your first invoice!

Tags: , , , , , , , , , | Posted under Textpattern | RSS 2.0

Author Spotlight

Pete Cooper

Pete Cooper has been using Textpattern since 2005. Textpattern is his preferred CMS weapon of choice. Its logical and flexible approach to content management makes Pete happy, as does its lightweight core and helpful user community. Pete's website - petecooper.org - runs on top of Textpattern and chronicles his day-to-day experiences from his home near the Atlantic in north Cornwall, United Kingdom.

Leave a Reply

Your email address will not be published. Required fields are marked *