lessons/v4/adding-custom-fields-to-a-page having issues with a varchar value not displaying.

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

Silverstripe Version:
SS4.3
Question:
Struggling to get $Author to display only displaying blank value even though the database is holding a value. Could anybody possibly tell me why I am not able to call this variable from the database?
Details of query:
I am new to SilverStripe and have been working through the lessons. I am on lesson 6 “Adding custom fields to a page”. I’ve updated the “ArticlePage” class to generate the fields in the database and use the “FieldList” API to add some new form inputs.
No issues displaying $Date and $Teaser but $Author isn’t working. I’ve checked the GitHub repository to compare my code but unfortunately even though the “Tutor” tells you to use $Author to replace static values he/she hasn’t gone as far as to do the same.

ArticlePage.php

<?php
namespace SilverStripe\Lessons;

use Page;
use SilverStripe\Forms\DateField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\TextField;

class ArticlePage extends Page
{
  private static $can_be_root = false;

  private static $db = [
    'Date' => 'Date',
    'Teaser' => 'Text',
    'Author' => 'Text',
  ];
  public function getCMSFields()
  {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Main', DateField::create('Date','Date of article'),'Content');
    $fields->addFieldToTab('Root.Main', TextareaField::create('Teaser')
      ->setDescription('This is the summary that appears on the article list page.')
      ,'Content');
    $fields->addFieldToTab('Root.Main', TextField::create('Author','Author of article'),'Content');

    return $fields;
  }
}

ArticlePage.ss

...//
			<!-- BEGIN MAIN CONTENT -->
			<div class="main col-sm-8">

				<h1 class="blog-title">$Title</h1>

				<div class="blog-main-image">
					<img src="http://placehold.it/765x362" alt="" />
					<div class="tag"><i class="fa fa-file-text"></i></div>
				</div>

				<div class="blog-bottom-info">
					<ul>
						<li><i class="fa fa-calendar"></i> $Date.Long </li>
						<li><i class="fa fa-comments-o"></i> 3 Comments</li>
						<li><i class="fa fa-tags"></i> Properties, Prices, best deals</li>
					</ul>

					<div id="post-author"><i class="fa fa-pencil"></i> By $Author</div>
				</div>

				<div class="post-content">
					<div class="highlight-bold">$Teaser</div>

					<div class="divider"></div>
//...

The code looks fine, although it might make more sense to use Varchar for Author rather than Text. Is it possible you just need to publish the page?

Thank you. Sorry the datatype Text was meant as a test and got snucked in when I copied it to this post.
I’ve definitely published the page.

In addition to @JonoM’s answer, just in case, add ?flush to the end of the URL when you view the page. Especially if your site is in dev mode, template caches sometimes get in the way.

Yeah I’ve been using ?flush and /dev/build on regular intervals.

I’ve tested my code by including another field to ArticlePage.php to “replace” Author with Publisher. This seemed to work. So I am drawing a conclusion that the field name Author is not allowed to be used. For my sanity sake if anybody has an idea of why this is happening I would be thankful.

private static $db = [
‘Date’ => ‘Date’,
‘Teaser’ => ‘Text’,
‘Author’ => ‘Varchar’,
‘Publiser’ => ‘Varchar’,
];
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab(‘Root.Main’, DateField::create(‘Date’,‘Date of article’), ‘Content’);
$fields->addFieldToTab(‘Root.Main’, TextareaField::create(‘Teaser’)
->setDescription(‘This is the summary that appears on the article list page.’),
‘Content’
);
$fields->addFieldToTab(‘Root.Main’, TextField::create(‘Author’,‘Author of article’),‘Content’);
$fields->addFieldToTab(‘Root.Main’, TextField::create(‘Publiser’,‘Publiser of article’),‘Content’);

return $fields;

}

SS 4.7
Same problem, changing Author to Published didn’t help
And secont problem - https://www.silverstripe.org/learn/lessons/v4/adding-custom-fields-to-a-page-1

String as DataType in not allowed

I had problems last year, when I tried to follow the tutorials, I found watching the v3 videos helped. See my blog for details: Setup a new SilverStripe 4 Project [ Pen y Fan ]

You can see a branch for each lesson on Github: GitHub - Pen-y-Fan/silverstripe-lessons: SilverStripeCMS Lessons

I hope this helps, once you get your head around SilerverStripe it is great.