Can not get property of page to show on Template

Hi,

I followed this lesson: SilverStripe Lessons » Adding custom fields to a page » Silverstripe CMS

Then when I tried to take Date, Teaser to show in template, they worked well

But Author is different. Please see very simple sample code:

<div class="info-blog">
                                    <ul class="top-info">
                                        <li><i class="fa fa-calendar"></i>$PublishedDate.Nice</li>
                                        <li><i class="fa fa-comments-o"></i> 2</li>
                                        <li><i class="fa fa-tags"></i> Properties, Prices, best deals</li>
                                    </ul>
                                    <h3><a href="$Link">$Title</a></h3>
                                    <p>$Teaser</p>
                                    <p>$Author</p>
                                </div>

It can not be simpler but $Author is empty on page.

I tried to use another db field, $AuthorBy and the new one worked well.

So my question is why $Author special ? Why I can not get it in my template ?

It’s due to Author being an existing method name on the Versioned class, so the code gets a bit confused when it tries to display it. Changing the variable name fixes this, as you’ve discovered.

There’s a bit of info on this old thread: lessons/v4/adding-custom-fields-to-a-page having issues with a varchar value not displaying.

(and yes, the lessons do need to be updated to reflect this)

1 Like

Thank @Tim.
I haven’t used Versioned extension on my page
But my page extends Page, Page extends SiteTree. SiteTree use Versioned extension