Forum

Thread tagged as: Question, Problem, Api

How to create blocks with repeaters?

Hi,

I am creating a treatments section in a beauty site and I'd thought I'd take advantage of blocks as some treatments have text areas, images, pricing tables and a combination of both. The pricing table is a unique template that has multiple text fields wrapped in html markup.

I created a new block html file and I have used some perch:content with text area and the the blocks markup to the pricelist.html field. The pricelist field I would like to add multiple rows to the single "pricelist" block but it doesn't seem to work like that, is it possible to create repeaters in the pricelist block?

Priclist block

<perch:before>
    <table>
</perch:before>
        <tr class="<perch:every count="2">even</perch:every>">
            <th scope="row" data-title="Product">
                <perch:content id="treatment" type="text" label="Treatment" required="true" title="true" help="Enter treatment name"/>
            </th>
            <td data-title="Price">
                <perch:content id="price" type="text" label="Price" help="Price value in (£)"/>
            </td>
            <td data-title="Time">
                <perch:content id="time" type="text" label="Time" help="Treatment time"/>
            </td>
        </tr>
<perch:after>
    </table>
</perch:after>

Treatments Template

<perch:blocks>

    <perch:block type="textarea" label="Text Block">
        <perch:content id="text" type="textarea" label="Text" html="true" editor="ckeditor" imagewidth="640" imageheight="480" />
    </perch:block>

    <perch:block label="Pricelist" type="pricelist">
        <perch:template path="content/blocks/pricelist.html" />
    </perch:block>

    <perch:block type="image" label="Image">
        <img src="<perch:content type="image" id="image" label="Image" width="800" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="Banner image" title="true" />" />
    </perch:block>

</perch:blocks>
Andrew Cetnarskyj

Andrew Cetnarskyj 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Hi Andrew

you can use repeaters inside blocks but I don't see any perch:repeater tags in your template.

Rachel

I took them out as it wasn't working but I will try them again and see how I go.

I was putting them after perch:before in the price list template

Rachel Andrew

Rachel Andrew 394 points
Perch Support

we need to see the template that isn't working to be able to help.

Sorry, so what I can't get to work now is the dropdown to pick the table alignment, the content is just blank within the class.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does the select box appear on the edit form?

Yes in the back end dropdown appears and saves the state fine.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does it output on the page?

just a blank space like so...

<table class="  ">

Hi Andrew,

Can you try closing the tag like this /> rather than just >

So

<perch:content id="alignment" label="Alignment" type="select" options="left|Left, right|Right, full|Full" help="Pick an alignment" />