Skip to content

Model: Blog post

Ricky edited this page Jul 30, 2020 · 1 revision

Namespace: rbwebdesigns\HamletCMS\BlogPosts

Public properties

These are the properties of the Post class, custom modules may inject additional properties.

Property Datatype Notes
id int Primary key
title string 255 characters max
summary text
content text
blog_id int Foreign key on the blogs table
author_id int Foreign key on the users table
link string Slug for the post URL
draft boolean Is the post visible to anonymous users?
timestamp datetime Date when the post was created
tags string Comma-separated list of strings
teaser_image string Image filename with extension but does not include directory
type string Content type of post (e.g. standard, video, layout)
class string Used with PDO::FETCH_CLASSTYPE when fetching posts from the database (system)
initialautosave boolean Has this post been created as an autosave (system)

Public methods

These are the standard methods of the Post class, custom modules may inject additional methods.

Signature Return type Notes
tags() array Simply splits the tags string into an array so they can be looped over
save() boolean Creates or updates the corresponding record in the database, returns if the operation was successful
toArray() array Adds all properties into an array and returns
author() \rbwebdesigns\HamletCMS\UserAccounts\User
blog() \rbwebdesigns\HamletCMS\Blog\Blog
relativePath() string Relative path/URL for the post
url() string Absolute URL to the post (including blog URL)
isPublic() boolean TRUE if post is not a draft and timestamp is in the past
isScheduled() boolean TRUE if timestamp is in the future
previous() \rbwebdesigns\HamletCMS\BlogPosts\Post Previous post when ordered chronologically, null if this is the oldest post on the blog
next() \rbwebdesigns\HamletCMS\BlogPosts\Post Next post when ordered chronologically, null if this is the most recent post on the blog