Forum
Perch Block with repeater - curtail element output
Hi,
I have the following block:
<perch:block type="text" label="Links">
<style><perch:template path="sidebar_links_styles.css"/></style>
<h5><perch:content id="sidebarheading" type="text" label="Sidebar Heading"/></h5>
<perch:if exists="links">
<perch:repeater id="links" max="4">
<perch:before><ul></perch:before>
<li><a href="<perch:if exists="hypertextlink"><perch:content id="hypertextlink" type="text" label="Hypertext Link"/><perch:else/>mailto:<perch:content id="emaillink" type="text" label="Email Link"/></perch:if>"><perch:if exists="hypertextlink"><perch:content id="hyperlinktext" type="text" label="Hyperlink Content"/><perch:else/><perch:content id="emaillinktext" type="text" label="Email Content"/></perch:if></a></li>
<perch:after></ul></perch:after>
</perch:repeater>
</perch:if>
</perch:block>
but I am getting multiple <style></style>
elements being output.
I am wondering if there is another way to template the desired output minus the additional <style></style>
elements, and while it may not be much in the way of superfluous content, it is nonetheless duplicating what has already been output by Perch.
If anyone has any ideas on how I might go about reformatting this template, it would be well appreciated.
Thanks for all the assistance rendered by forum members thus far.
You should get those tags once for each time the block is used.
What are you seeing?
Hi Drew,
The source is as follows:
I know it is by design, that the two
<style></style>
elements are being output but I'm hoping to achieve a better design so if you have any ideas they would be greatly appreciated since I'm not sure if the only way is to have each<ul></ul>
in a separate Perch Block.Regards,
If you're only wanting the style tags once, could you not place them in the
<perch:before>
?It looks like you are adding the same block more than once:
And here:
A block tag outputs what's inside it. If you have
<style>
in your block template and add the block more than once on the same page, then the<style>
will be output to your document more than once because that's how you set up your block template.