Forum

Thread tagged as: Question

Pulling content from a block within another page

Hi

I've created some Perch blocks for a client to be able to create their own testimonial pages – using text, image and quote blocks. I want to pull the content from one of these blocks on to the homepage to use as an excerpt.

I'm pulling in the testimonial's title and image but not sure of how to do the same for a block.

Is this possible?

Thank you!

David Maxwell-Wood

David Maxwell-Wood 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, include just that one block from the <perch:blocks> section in your template for the homepage - if the other blocks aren't there in the template they won't be output.

It doesn't seem to be outputting anything. So, for instance if I have this in a template –

<perch:blocks>
    <perch:block type="text" label="Text">
        <div class="article__text-block">
            <perch:content id="article_text" type="textarea" html="true" editor="redactor" label="Text content" />  
        </div>
    </perch:block>
</perch:blocks>

I should just be able to put this in a template for the homepage and it would pull in that block –

<perch:content id="article_text" type="textarea" label="Text content" />    

Or am I missing something?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It needs to be in the context of the block. So your homepage template would need to be:

<perch:blocks>
    <perch:block type="text" label="Text">
        <perch:content id="article_text" type="textarea" html="true" editor="redactor" label="Text content" />  
    </perch:block>
</perch:blocks>