Forum
Maybe a bug? perch_template()
Drew, I found that when I have a template with...
<perch:before>before html</perch:before>
MAIN_HTML
<perch:after>after html</perch:after>
if I use...
perch_template('content/template.html', array('tag'=>'value'))
the output html will not include the html between the before and after tag sets but... if I use
perch_template('content/template.html', array( array('tag'=>'value') ));
then I get the output of before and after tags in the output html.
Is this the expected behaviour of this function? I'm thinking not, because before and after should be included even when a single array "item" of tags is sent to the function for templating.
Please, explain... :)
BTW: Perch Runway 2.8.2
Before and after sections are for templates that display multiple items. If you're only displaying one item, they make no sense to include.
Ok... I accept your answer, except the part about making no sense for single items.
Multiple Item Regions may at times only have a single item. If this is region is "returned" for additional processing then sent back through perch_template() as a single item without being an [array()] then the before/after tags would not be included. So a second template would have to be created for single items.
Not trying to pick a fight, just wanting to make sure I understand EVERYTHING I can about perch and how certain things work.
Thanks for a GREAT product.
It's about the context. If you template an associative array, that is one item. No before and no after, as they don't make sense.
If you template a numerically indexed array of associative arrays -- no matter how many associative arrays are included, one or more -- then you get the before and after sections.
Great, and this is functioning as you explain. What I was needing to learn (which I have) is how to use a single item (recycling existing multi-item template) within a template which was created for multiple items.
Like I said, I understand why it works the way it does... So I wanted to learn the proper way to utilize the function.
:)