Forum
using page attributes as template include in perch_collection not working
Hi,
I'm trying to output page attributes (meta info in the head) for a runway collection item using a template include i.e.:
perch_collection('Walks', [
'template' => 'collections/_meta.html',
'filter'=> 'slug',
'match' => 'eq',
'value' => perch_get('walkSlug'),
'count' => 1,
]);
_meta.html
<perch:template path="pages/attributes/default.html" rescope="parent" />
The template markup is output but without any data / variables (<perch:pages id="description">, etc are empty).
If I copy & paste the contents of default.html into _meta.html and replace all perch:pages tags with perch:content tags the data variables are output fine, so there is a solution but it makes sense to be able to rescope & reuse these page attributes templates... Should this be possible?
Thanks!
If you turn on debug, what does it output at the bottom of the page?
Debug showing the templates are found (template markup is present to prove it) - it just doesn't insert the data where the template tags are.
Does
<perch:showall>
show the ID values you're using in the template?Thanks Drew.
Yes <perch:showall> displays all the ID values used in the template, they're just not output in the markup. I wondered if there were 2 many levels of template includes, as default.html contains 3 further template includes (seo, facebook & twitter). I had to update the paths for these, i.e. default.html:
Also added rescope="parent" to each include above and called default.html directly from perch_collection, i.e.
Same deal, <perch:showall> displays the ID values I'm trying to use but they're not output by the template, only the markup is.
I'm using the following to set the values in php before any markup is output:
Seems like the problem is rescoping from <perch:pages> template tags?
Could you post your diagnostics?
Here you go - thanks!
Was this an issue with template nesting depth?
No, without any nested templates it's still not working. Tried the following also as a variation of the above:
_meta.html:
<perch:showall> displaying the correct ID values in template as expected. Any further suggestions ideas as to what the issue might be here?
Thanks again!