Forum
Using template includes with blocks
I’m trying to use an include within a perch block, but the included template is not showing up. Is there something obviously wrong with my template?
<perch:blocks>
<perch:block type="text" label="Testimonial">
<perch:template path="testimonial.html" />
</perch:block>
<perch:block type="text" label="Text">
<perch:content id="text" type="textarea" markdown="true" editor="markitup" size="l" label="Text" />
</perch:block>
</perch:blocks>
It shows the Text block available to add but not the testimonial one.
Here is my diagnostic report:
SUMMARY INFORMATION
Perch: 2.8.13, PHP: 5.5.17, MySQL: 5.5.38, with PDO
Server OS: Darwin, cgi-fcgi
Installed apps: content (2.8.13), assets (2.8.13), categories (2.8.13), perch_blog (4.6)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/TwoLittleFishes/Dropbox/sites/helenaclayton.co.uk/perch
PERCH_CORE: /Users/TwoLittleFishes/Dropbox/sites/helenaclayton.co.uk/perch/core
PERCH_RESFILEPATH: /Users/TwoLittleFishes/Dropbox/sites/helenaclayton.co.uk/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /Users/TwoLittleFishes/Dropbox/sites/helenaclayton.co.uk
HTTP_HOST: helenaclayton.local
Hi Nick
Is
testimonial.html
template in thecontent
folder or is it in a sub-folder within thecontent
folder?If it is you may need to add that to the path...
Yes the testimonial.html file is in the main templates/content folder.
Try
Thanks Drew,
it seems to work with or without the /content as the debug in both shows:
It looks like the problem might be with the testimonial.html template, which works fine alone but may be doing something odd in a block, here is the complete code (instead of using the include) which still only shows the option to add Text:
Just discovered changing it to:
works, the difference is that the testimonial block now has a type of textarea, instead of text. The second block though works with a type of text even though the content has a type of textarea.
You can't have two blocks of the same type. You'd be better to use
type="testimonial"
for your Testimonial block - it's more descriptive of what you're actually doing.Thanks Drew, I hadn’t realised that the perch:block type acted as an ID, I thought it worked like the perch:content type.