Forum

Thread tagged as: Suggestions, Discussion

Template Includes

Just a very small suggestion:

It would be handy to be able to re-use includes in a template:

I modified the out-of-the-box text area text_block.html to use Redactor and adjusted the images sizes slightly:

<perch:content id="text" type="textarea" label="Text" html="true" editor="redactor" imagewidth="750" imageheight="500" />

Now I can call that text area within another template:

<perch:template path="content/text_block.html" />

But what I can't do is use it twice in a template, because it has an ID:

<perch:template path="content/text_block.html" />

<perch:repeater id="conference_logos" label="Conference/Shows">
  <a href="<perch:content id="url" type="text" label="Website" />" target="_blank">
    <img src="<perch:content type="image" id="conference_logo" label="Logo" width="250" height="80" />" alt="<perch:content type="text" id="conf_title" label="Conference/Show Title" />" />
  </a>
</perch:repeater>

<perch:template path="content/text_block.html" /> <!--no can do, because it will have the same ID as the one earlier in the template-->

It's feasible that in some templates there will be more than one text area, so it would be handy if I could re-use templates in this way and give it a new ID a bit like rescoping:

<perch:template path="content/text_block.html" id="new_id_here" />

Just a thought.

Simon Clay

Simon Clay 127 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What would that do, prefix all the IDs in the sub template?

Would it be worth the runtime performance trade-off?

Simon Clay

Simon Clay 127 points

I take your point.

I was only thinking of a single item in a sub template.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think it would need to work however many fields (and repeaters etc) are in the sub template.

Not impossible to do, but something that would need to be carefully considered.