The Blog Module
The blog module allows you to easily setup a blog at www.yoursite.com/blog. It supports features like custom post fields, post previews, draft posts, blog categories, blog tags, blog keywords, and blog comment expiration. This section discusses how to create and manage a blog on PyroCMS.
Blogging Basics
You can find the blog content controls under Content → Blog. This lists all of your posts, their post status, author, and category. It also has an option to publish one or more posts in draft status.
To create a new post, click + Add Post in the top right corner.
This will bring up the blog post form, which has three tabs:
- Content
- Custom Fields
- Options
Basic Blog Fields
The blog comes with some basic fields that are the core fields that the blog relies on to function.
Under the Content tab, the following fields are available:
| Field | Default Value | Notes |
|---|---|---|
| Title | This is the title of the post. | |
| Slug | The URL segment identifying the post. This is auto-generated, but you can edit it. For example, your title is "My favorite Animals", the slug will be "my-favorite-animals". | |
| Introduction | A shorter version of your blog post that appears on the blog index pages. | |
| Content | The full blog post. |
Under the Options tab, the following fields are available:
| Field | Default Value | Notes |
|---|---|---|
| Category | A single category for the blog post. If you need to create a new category, you do so right there by clicking Add a Category. | |
| Keywords | Keywords for the blog post. | |
| Date | Current date/time | Date/time of the publication of the blog post. This will not affect when the blog post is visible - only the draft/live status affects whether the post is live. |
| Comments Enabled | Three Months | Whether or not to enable comments on this post. This allows you to set a timeframe that you'd like users to submit new comments within. This ranges from One Date to Three Months. You can also set this to No to turn comments off for this post, as well as Always to leave comments on indefinitely. PyroCMS calculates whether or not posts should be shown or not based on your post date value. |
Custom Blog Fields
Blogs sometimes need extra functionality beyond just the basic blog post body and title. That's why you can extend the functionality of the blog module but adding custom blog fields.
To add new fields, click on Custom Fields on the module sub navigation. By default, PyroCMS adds an Introduction WYSIWYG field. If you don't need an introduction field, you can simply remove this.
You can use any of your core and add-on field types as blog fields. After adding them, you'll need to display them by overloading the basic blog templates.
Blog Previews
Blog posts need a way to represent themselves on things like post lists/archives, and RSS feeds. When displaying posts, PyroCMS first looks for a custom field with a slug called intro. If it can't find that, it will use the entire blog post body.
You can always override this in your overloaded blog views in your theme, but by default, PyroCMS will use the logic above.
URLs
The blog module has its front-facing view at:
/blog
Each post shows up in the following format:
/blog/{year}/{month number}/{post slug}
Category archives can be viewed at:
/blog/category/{category slug}
Keyword archives can be viewed at:
/blog/tagged/{tag}
Blog RSS Feed
You can find you blog rss feed at:
/blog/rss
The blog module will also add an application/rss+xml link tag to the header of all pages of your site if the blog module is enabled.
Customizing Blog Display
The blog can be customized via view overloading in your theme. There you can adapt the code to suit your display needs.
The views available for overloading are:
| View | Notes |
|---|---|
| archive.php | View used for category and keyword archives. |
| posts.php | View used for the main posts listing. |
| view.php | View used for displaying a single blog post. |
| rss.php | View used for the RSS feed. |
The archive, posts, and view views all use PyroCMS tags.
The following tags are available to use by default in the post tags.
{{ pagination }}
A string of auto-generated pagination for the blog posts.
{{ posts }}{{ /posts }} or {{ post }}{{ /post }}
A tag pair containing either a list of posts (like in archive.php and posts.php) or a single post (like in view.php). Available inside this tag pair are the following tags:
{{ title }}
The blog post title.
{{ slug }}
The blog post slug.
{{ url }}
A link to the full blog URL (Only available in the {{ posts }} loop).
{{ keywords }}
Any keywords associate with this post.
{{ keywords }}
<a href="blog/tagged/{{ keyword }}">{{ keyword }}</a>
{{ /keywords }}
{{ category }}
The category associated with the blog post. Two variables are available for this tag: slug and title.
<a href="blog/category/{{ category:slug }}">{{ category:title }}</a>
{{ body }}
The blog post body.
{{ preview }}
An automatic preview of blog post. PyroCMS first looks for a custom field with a slug called intro. If it can't find that, it will {{ body }}.
{{ created_on }}
A unix timestamp of when this blog post was created. It is usually used in conjection with the date helper.
{{ helper:date timestamp=created_on format="F j, Y" }}
{{ created_by }}
The ID of the author of the post. This is usually used in conjunction with the user plugin to retrieve profile data about the user.
{{ user:display_name user_id=created_by }}
Blog Widgets
The blog module has a lot of handy widgets. A common practice is to create a blog widget area to show on the left/right hand side of the blog indexes.
Blog Plugin
You can also access blog posts with the blog plugin.
