Forum
How do I use a custom template for a blog post?
We use multiple blogs and one blog uses the default template (post.html) for my detail post page. Like:
<?php perch_blog_post(perch_get('s')); ?>
I like to use a custom template for the other blog. Something like:
<?php
perch_blog_custom(array(
'filter' => 'slug',
'blog' => 'news',
'template' => 'post_en.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('s'),
'count' => 1,
));
?>
By using this code we manage to get the correct template but it doesn't show any content. How is this possible?
Thanks!
What's in your template? Did you start with a copy of
post.html
?Yes, did start with a copy. Here is the customized template:
Ok, that looks ok.
Do you get any output at all?
Debug message shows two templates being used.
Do you get any output at all?
Yes, now we manage to output the content, but it uses the default template (post.html), not the post_en.html that we like to use.
What does your page function look like?
Do you mean this one?
Yes, that's the one. So you're saying that even though you're specifying
post_en.html
a different template is being used? Does that match what the debug output says?Is the repeated 'filter' in the array doing something funny here?
Yes, that match what the debug output says. Removed the repeated «filter» without any new result.
Can you show us the debug?
Yes, here:
And this is the exact code you're using?
This is the correct code (removed the repeating filter):
Is this the path to your template?
No, it´s not.
The right path is: /dv-cms/templates/blog/post_en.html
Changed the filter ID from «slug» to «postSlug» and now it works fine ;-)