Using the txp yield tag for flexible results

I must admit to have never using the relatively new txp:yield tag until today – its one of those tags that appears difficult to understand but actually offers a site developer a lot of flexibility.

On the TextBook page entry for the yield tag there is one example of usage – the following example features one method for using one form repeatedly with a variable limit="" attribute.

In your page template

<txp:output_form form="your_form_name">25</txp:output_form> 

Notice the 25 in the output_form container tag? That will be passed on to your worker form in the next step.

The form contents

<txp:article limit='<txp:yield />' form="some_other_form" />

The yield takes the 25 value from the outputted form in your page template and sets this as the article limit value. This is a very useful method if you need to use the same form over and over again in your site but with variable attributes.

comments powered by Disqus