Forum

Thread tagged as: Question, Blog

Blog post meta information

In my post.php after the call for the blog post I have a call for an author template that looks like this:

<div class="module author">
    <perch:if exists="author_image">
        <img src="<perch:blog id="author_image" type="image" label="Image" width="240" height="240" crop="true" density="2" order="5" />" width="120" height="120" alt="<perch:blog id="authorGivenName" type="text" label="Given name" order="1" /> <perch:blog id="authorFamilyName" type="text" label="Given name" order="2" />" />
    </perch:if>
    <div class="hcard">
        <pclass="fn n">This post was written by <a href="/blog/archive.php?author=<perch:blog id="authorSlug" type="text" />"><perch:blog id="authorGivenName" type="text" label="Given name" order="1" /> <perch:blog id="authorFamilyName" type="text" label="Given name" order="2" /></a> on <perch:blog id="postDateTime" format="%d %B %Y" /> in <?php perch_blog_section(perch_get('section')); ?> and tagged <?php perch_blog_post_tags(perch_get('s')); ?>.</p>
    </div>
</div>

It correctly displays the post author and their photo, but is not showing the date, section name or the tags for the post. I don't really understand why, hoping someone can help me please.

Thanks.

Phil Bowell

Phil Bowell 0 points

  • 6 years ago

I just realised I was trying to use php inside of a html template. I've corrected the tags one (not sure how to do the section one) but it doesn't actually display any tags (yes they are there).

<div class="module author">
    <perch:if exists="author_image">
        <img src="<perch:blog id="author_image" type="image" label="Image" width="240" height="240" crop="true" density="2" order="5" />" width="120" height="120" alt="<perch:blog id="authorGivenName" type="text" label="Given name" order="1" /> <perch:blog id="authorFamilyName" type="text" label="Given name" order="2" />" />
    </perch:if>
    <div class="hcard">
        <pclass="fn n">This post was written by <a href="/blog/archive.php?author=<perch:blog id="authorSlug" type="text" />"><perch:blog id="authorGivenName" type="text" label="Given name" order="1" /> <perch:blog id="authorFamilyName" type="text" label="Given name" order="2" /></a> on <perch:blog id="postDateTime" format="%d %B %Y" /> in <?php perch_blog_section(perch_get('section')); ?> and tagged <perch:before><ul></perch:before>
            <li><a href="archive.php?tag=<perch:blog id="tagSlug" />" rel="tag"><perch:blog id="tagTitle" /></a></li>
<perch:after></ul></perch:after>.</p>
    </div>
</div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which page function are you using to display this template?

I'm using this

 <?php perch_blog_author_for_post(perch_get('s'), array(
        'template' => 'author_post.html',
    )); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_blog_author_for_post() will give you the author, but not the post.

So what is the best way to call that template?

<div id="blog">

    <div class="post">
        <?php perch_blog_post(perch_get('s')); ?>
    </div>

    <?php perch_blog_author_for_post(perch_get('s'), array(
        'template' => 'author_post.html',
    )); ?>

</div>

It was initially just calling the author, but I realised I needed to include the other information in that template. I'm not a php person, I do html & css fine, so I would appreciate any guidance please.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you should have all that available in the main post template - there may be no reason for splitting it into two.

Thanks Drew, I've reverted back to the original post.html and have the date and author working. The only thing I don't seem to be able to get to work is to display the tags or the blog section. I've tried to use the contents of post_tag_link.html inside post.html but it doesn't seem to display the tags.

I imagine it's very simple, I'm just over thinking things.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does <perch:showall /> list your tags?

Yes, that shows the tags under postTags.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So does this work?

<perch:blog id="postTags" />

It does, thank you! I knew it would be simpler than I was trying to make it.