Setting Up a Blog With the 'blog' Module
Setting up a blog in Mercury is very straightforward. Follow a few simple steps and you'll be up and running in no time!
Enable the blog module
Using the techniques described in the seciton What does it mean to enable a module you need to enable the blog module.
Set up some categories
Log into the site and go to your admin area. Now that the blog module has been enabled you will see a section at the top for BLOG.
Click on the Categories link and then the Add link. Enter a category name and an optional description. (Right now the description is not really used, it's in there for forward planning) Even if you don't plan to split your posts into categories you must still have at least one. If this is the case for you give it a generic name like 'General' or 'Writing'.
Repeat as many times as needed to enter your categories.
Set up a user account (or two or three) and give them posting access
Follow the instructions in Adding a User Account In the Admin to create a new user account for posting blogs. Technically you don't need to do this as you could use the root user but most sites will benefit from some added personality and one or more additional accounts. Edit their Permissions to assign this user the "Blog - Can Post" permission and, optionally, the "Blog - Can Post In All Categories" permission.
Repeat for as many login accounts as needed.
Build a way for people who have logged in to get to the Post A Blog page
The following code shows how to show a link to the blog-posting page for authorized individuals. You can put this in your layout.php or anywhere else you'd like.
<?php
if(m("blog", "canPost", $_SESSION['LoginId'])){
echo "<A HREF=\"/blog/post-article\">Post Blog</A>";
}
?>
Remember that permissions are set when someone logs in. This means that someone who is NOT logged in will never have permissions to see that link. If someone without permissions attempts to go to that link path they will not see the form that authorized accounts will see.
Files for Default Layout and CSS
This zip archive contains all of the files that make up the default layout for the blog module as well as a sample CSS file to go with them. If you choose to use the default layouts then you will not have to update ANY of the display files but you WILL have to make sure that the CSS file get included or incorporated into your primary site CSS file.
Note: The CSS file contains some formatting for a couple comment and user elements that are likely to be defined sitewide. They are included here because they are necessary to make the default layout function properly. You may choose to define those elsewhere.
Download default display + CSS
This second zip file contains an alternate layout system that is used on the WebKit.com blog. This is an example of a layout that was created from scratch. None of the default files were used, this is the HTML creation of the WebKit graphic designer that was modified by putting the right varibles in the right places.
Download WebKit.com display files and CSS
The entire style sheet for the WebKit site is included because other formatting elements (like links and headers) are part of what is used to style the blog.
Formatting your blog
As mentioned you can use the default layout and simply modify the provided CSS to style your blog. If you are trying to snap your fingers and create a site then this might be the way to go. If, however, you are trying to create a more custom look and feel you would do well to create your HTML layout from scratch and use some display overrides like those provided in the WebKit layout.
In the WebKit layout you can see how three override files plus a CSS file change everything. You don't have to override everything, just choose the files that you'd like to customize. You can also start with the default files and one-by-one implement your custom overrides.
Functions You Can Use
The following functions can be used as you build your blog layouts. You will need to make sure the right variable is put into the fields that are in bold/italics.
Link to a post:
<A HREF="<?= m("blog", "getPostLink", BlogPostId); ?>">
Show a user 'stamp;:
<?= m("users", "loginStamp", LoginId); ?>
Variables You Can Use
This section will focus on the variables that you can use in your blog display files, primarily on two pages.
html/mercury/blogs/display/display-multiple-posts.php
This file loops over a list of posts and includes the following file.
html/mercury/blogs/display/display-short-post.php
This file makes use of an array called $post. You will have access to the following variables:
$post['BlogPostTitle'] - The title of the post
$post['BlogPostTagline'] - The subheader of the post
$post['AddedDateTime'] - The date and time the post was made
$post['Username'] - The username of the account that made the post
$post['LoginId'] - The login id of the account that made the post
$post['BlogCategoryName'] - The name of the category the post was created in
$post['BlogPostText'] - The post of the text, not including the part that comes after "Read More".
$post['HasMore'] - Either 1 or 0. It's 1 if there is content in the BlogPostMoreText variable (not used on this page).
$post['CommentCount'] - The number of comments that are currently on this blog
$post['BlogPostId'] - The numeric id of this post
$post['FileName'] - If there is an attached file, the name of that file. If not, then blank.
$post['AltText'] - The ALT text for the attached file
Link to the dedicated page for this post with: <A HREF="<?= m("blog", "getPostLink", $post['BlogPostId']); ?>">
Show the quick login profile for the user that made this post with : <?= m("users", "loginStamp", $post['LoginId']); ?>
html/mercury/blogs/display/display-full-post.php
This file makes use of an array called $post. You will have access to the following variables:
$post['BlogPostTitle'] - The title of the post
$post['BlogPostTagline'] - The subheader of the post
$post['AddedDateTime'] - The date and time the post was made
$post['Username'] - The username of the account that made the post
$post['LoginId'] - The login id of the account that made the post
$post['BlogCategoryName'] - The name of the category the post was created in
$post['BlogCategoryId'] - The numeric id of the category the post was created in
$post['BlogPostText'] - The post of the text, not including the part that comes after "Read More".
$post['HasMore'] - Either 1 or 0. It's 1 if there is content in the BlogPostMoreText variable (not used on this page).
$post['CommentCount'] - The number of comments that are currently on this blog
$post['BlogPostId'] - The numeric id of this post
$post['BlogPostMoreText'] - The post of the text from the "Read More" part. May be blank.
$post['FileName'] - If there is an attached file, the name of that file. If not, then blank.
$post['AltText'] - The ALT text for the attached file
Link to the dedicated page for this post with: <A HREF="<?= m("blog", "getPostLink", $post['BlogPostId']); ?>">
Show the quick login profile for the user that made this post with : <?= m("users", "loginStamp", $post['LoginId']); ?>
