Forum

Thread tagged as: Question, Runway, Blog

Display blog author information within the post.html template?

I've set up a blog and the design calls for displaying the author name and image between the h1 and the body of the post. It appears that you can only pull that information in via the post.php template, but then it's not possible to display it in the required place.

Here's my current template, with the non-functioning author fields.

<main class="wrap" id="skipnav"> 
<div class="row bgdeepaqua" style="height:auto;"> 
  <div class="container" style="padding:0;"> 
    <div class="row"> 
      <div class="eight columns offset-by-two"> 
        <p style="text-transform: uppercase;font-size:.875em;" class="yellow">
            <perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes">
              <a href="archive.php?cat=<perch:category id="catSlug" type="slug">">
                <perch:category id="catTitle" type="text">
              </a>
            </perch:categories>
        </p>
        <h1 style="font-weight:600;color:#fff;font-size:1.75em;margin-bottom:1em;margin-top:1em;"><perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /><br />
        <perch:if exists="postSub"><perch:blog id="postSub" type="text" label="Subhead" size="xl autowidth" order="2" /></perch:if></h1>
            <p class="postauthor"><perch:blog id="authorGivenName" />  <perch:blog id="authorFamilyName" /></a></p>
            <img src="<perch:blog id="photo" width="72" />" alt="Photo of author" class="authorphoto">">
            <p class="authorposition"><perch:content id="position" /></p>
        </div>
    </div>
  </div>
</div>
<div class="container" style="padding:1em;"> 
  <div class="row"> 
    <div class="eight columns offset-by-two"> 
        <p><perch:blog id="postDateTime" type="date" time="true" format="Y-m-d H:i:s" label="Date" suppress="true" /> <span style="background-color:rgba(123,164,175,1);margin-left:1em;width:auto;padding:4px 8px;color:#fff;font-weight:800;border-radius:3px;">tag</span></p>
    </div>
  <div class="row"> 
    <div class="eight columns offset-by-two" style="margin-top:-16px;">
        <perch:blog id="postDescHTML" type="textarea" label="Post" order="3" editor="ckeditor" html="true" size="xxl autowidth" required="true" />
    </div>
  </div>
</div>
<div class="container"> 
    <div class="row">
        <div class="ten columns">
            <perch:blog id="postDescHTML" type="textarea" label="Post" order="3" editor="ckeditor" html="true" size="xxl autowidth" required="true" />
        </div>
    </div>
</div>
<perch:blog id="excerpt" type="textarea" label="Excerpt" markdown="true" order="5" size="m" suppress="true" />
<perch:blog id="postSlug" type="slug" for="postTitle" indelible="false" label="Slug" suppress="true" />

and my post.php

<?php perch_blog_check_preview(); ?>
<?php perch_layout('global.header', array(
       'title' => $title
       ));
?>
<?php
$post = perch_blog_custom(array(
  'template'        => 'blog/post.html',
  'filter'          => 'postSlug',
  'match'           => 'eq',
  'value'           => perch_get('s'),
  'skip-template'   => true,
  'return-html'     => true,
  'blog'            => 'blog',
));
?>
<?php perch_layout('global.footer'); ?>

Is it really not possible to choose where the author information is displayed? If not, can the built-in blog author capability be removed and built as a separate blog template.

Probably missing something obvious, as I sometimes do.

Thanks, Tim

Timothy Swan

Timothy Swan 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I thought the author info was always there. Do you see it with <perch:showall> ?

Remember that the type attribute is required, and in a blog template you need perch:blog tags, not perch:content.

Thanks Drew. Using <perch:showall> helped me to identify the problem and it's working now.