Basic Blog

From MODx Wiki
Jump to: navigation, search


Here's how to use the MODx CMF to create a simple blogging system with comments, and an easy to use method of adding "blog" entries. In this tutorial, we will use two chunks, and two documents.

Snippets Used

The following three snippets are included in the default installation of MODx versions 0.9.2 to

  • NOTE that the NewsPublisher snippet is no longer included from MODx 1.0.0 on (because it does not support Template Variables). It will still work, but you will have to obtain and install it. The demo blog in the distribution package now expects you to use Quick Manager to write your blog as a manager user, with the advantage that you have full access to template variables for tags etc. Simply go to the Blog Page (container) and using QM click "Create Resource Here". Edit Blog Post and Save.
  • Ditto - Shows a number of documents in a "summary" on a webpage.
  • Jot - Keeps track of comments that users post to each document (blog).
  • NewsPublisher - Creates a form on a page that can be used to add blogs.

NOTE: MODx version 0.9.5 - Jot needs to be updated to the latest version.

Chunks Needed

Let's start by creating the chunks, create two chunks using the directions below.


  1. Go to Resources -> Manage Resources and click on Chunks tab.
  2. Then click on "New Chunk" and insert:
[[Jot? &subscribe=`0` &pagination=`10`]]
[!Jot? &subscribe=`0` &pagination=`10`!]

into the chunk contents. The name of chunk should be "CommentsBlog". We need this chunk to insert a "comments" link at the bottom of every page. (New installations of MODx include a 'Comments' chunk which references the Jot snippet in a similar fashion).


  1. Go to Resources -> Manage Resources and click on Chunks tab.
  2. Click on "New Chunk" and insert:
	<a href="[~[+id+]~]" title="[+title+]">[+title+]</a>
</h3> <!-- link to blogs article with it's title (link is title) -->
By <strong>[+author+]</strong>
on [+date+].
<a  href="[~[+id+]~]#commentsAnchor">
	Comments ([[Jot? &docid=`[+id+]` &action=`count-comments`]])
</a><!-- link to the article with comments form and comment count -->
Summary: [+introtext+]
<br />
Link: [+link+]

into the chunk contents. The name of chunk should be "BlogTemplate". This is the chunk that describes how to display the blog article when using ditto. More about this later. Don't forget you could use a template variables e.g. [+TemplateVariable+] rather than [+title+] Please note the placeholder for the Summary is now [+introtext+]. [+summary+] is no longer supported natively. See the Ditto documentation.

Pages Needed


Create this page first!

  1. Click on Site -> NewDocument. Page name should be show_blog (or whatever you want).
  2. Remember the ID of this document as it will be needed for the next page. MODx gave ID 43 to this document.
  3. In page source insert following code:
[!Ditto? &parents=`43` &summarize=`2` &total=`20` &commentsChunk=`CommentsBlog` &tpl=`BlogTemplate`!]
  • &parents - Should be the ID of this page, because the NewsPublisher snippet will put all new articles on this page, and Ditto will just read and show them all (previous to Ditto 2.x use &startID, see note).
  • &summarize - The number of documents to show using &tpl.
  • &total - Show remaining documents as links up to this number.
  • &commentsChunk - Chunk used to display your comments (the chunk will be removed when summarizing).
  • &tpl - How to format summary documents

Note: As of Ditto 2.x the &startID parameter has been replaced with the &parents parameter. See the Ditto documentation, and &summarize has been replaced by &display See the Ditto documentation.


Click on Site -> NewDocument. Page name should be input_blog (or whatever you want). Remember the ID of the document. MODX gave ID 38 to this document.

In page source insert following code:

[!NewsPublisher? &folder=`43` &footertpl=`CommentsBlog` &makefolder=`1`!]
  • &folder - where to put newly created articles, this ID will be ID of SHOW_BLOG page!!!
  • &footertpl - added to the bottom of every article published (this is used for comments).
  • &makefolder - automatically convert SHOW_BLOG document to a folder.

Friendly URLs

If you have friendly urls set up with friendly alias path enabled you need to add

<base href="[(site_url)]"></base>

Right after your opening <head> tag in your template.


That's all there is to it. A couple things to keep in mind:

  • Modx will show an error if there are no blog articles, so, insert few articles before testing commenting...
  • In the SHOW_BLOG page, if &parents is not specified, the current document will be used.
  • In the INPUT_BLOG page, you can remove the &makefolder parameter after first use for a small speed boost (one less query to the database each time you post).


Personal tools