Template for Blog postTag Template Tag
I have modified post_in_list.html to display the post tags below each post by including
<perch:blog id="postTags" />
however, this is not what I want as it just spits out an unstyled list of the tags for each post. Is there a template for Template Tags (https://docs.grabaperch.com/addons/blog/template-tags/), or am I missing the point? What I would like is a list of the tags that link to the tag archive pages (/archive.php?tag=mytag) - how can I insert that in post_in_list.html?
Thanks, Mike.
Have you tried
perch_blog_post_tags()
?https://docs.grabaperch.com/addons/blog/page-functions/perch-blog-post-tags/
I can't use php in a template though, so would I need to include a layout file to do this?
You can generate the HTML outside of the template and then pass it in.
https://docs.grabaperch.com/docs/templates/passing-variables-into-templates/
I'm still not getting it I'm afraid. This is what I have done:
/blog/index.php
post_in_list.html
This doesn't output anything :(
You need to return the value, so try:
Still getting nothing I'm afraid Drew. I think the problem is that it needs to be called from within the template else it won't work.
That's not the case, no.
Can you turn on debug and let me know what it outputs?
What's the value of
?s=
in your query string?Do you mean in a post URL? As in "post.php?s=2015-12-17-our-first-blog-post"
Right - that looks ok, but for some reason it's not coming through:
Any ideas why? Just to clarify I am calling this from the main blog index.php page rather than the post page itself so would the post slug not become available until cycling through perch_blog_recent_posts(10)?
Can you show me the code you have on that page?
Sure Drew, see below:
/blog/index.php:
post_in_list.html:
If this is
/blog/index.php
then you don't have a specific post to show, do you?Yeah, that's what I was trying to say. Hence why I asked you if I could call this from within the post_in_list.html template file? It seems clear to me that it should be called from within the loop, not outside as you previously seemed to suggest.
You'd need to use an
each
callback for that.Sorry Drew, I'm even more confused now, where am I putting this code in my files? Plus, am I supposed to replace 'each' as this doesn't look like valid PHP? In fact if I put this in my /blog/index.php page I get a syntax warning (Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW)). And what is 'tags_html'?
I'm afraid you are going to have to explain this in dumb terms and break it down as to how and where to use this - sorry!
Thanks, Mike.
each
is an option you can add to yourperch_blog_custom()
options array.Replace this:
with
Then in your template you can use:
I'm getting a syntax error with this code: Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) on this line:
I assume this should be
It still doesn't work anyway and shows this error in diagnostics now: