Making a basic blog with article comments with MODx 0.9.5.
(required snippets: Ditto, Jot, NewsPublisher):
I have tried to find tutorial for creating basic blog with ability to comment articles almost 2 days,
there are few, the wiki page is most comprehensive, but there isn’t one which gave me a complete solution,
so, I have decided to write one step by step (I assume that you are familiar with MODx commands, so, I will
not go deep in commands explanation.):
First, we need two documents:
- input_blog document (to write articles, modx gave ID 42 to this document, yours ID may be different)
- show_blog document (to show blog articles, modx gave ID 43 to this document)
Chunks needed:
1. "CommentsBlog"
We need to create the "CommentsBlog" chunk.
Go to Resources/Manage Resources and click on Chunks tab.
Then click on "New Chunk" and insert :
[[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.
2. "BlogTemplate"
BlogTemplate is chunk which describes where to put blog article, where to put link to comment.
Go to Resources/Manage Resources and click on Chunks tab.
Then click on "New Chunk" and insert :
<br />
<h3>
<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`!]) <!-- link to actual article with comments form and comment count -->
</a>
Summary: [+summary+
<br />
Link: [+link+]
into the chunk contents.
The name of chunk should be "BlogTemplate".
Pages needed:
1. INPUT_BLOG page:
Click on Site / NewDocument. Page name should be input_blog (or what ever you want).
MODX gave ID 38 to this document.
In page source insert following code:
[!NewsPublisher? &folder=`43` &footertpl=`CommentsBlog` &makefolder=`1`!]
&folder=`43` - where to put newly created articles, this ID will be ID of show_blog page!!!
&footertpl=`CommentsBlog` - after article is written, what to put in articles footer (this is used for comments)
&makefolder=`1` - after article is written, it will be inserted like subfolder (parent of INPUT_BLOG page
2. SHOW_BLOG page:
Click on Site / NewDocument. Page name should be show_blog (or what ever you want)
MODx gave ID 43 to this document.
In page source insert following code:
[[Ditto? &startID=`43` &summarize=`2` &total=`20` &commentschunk=`CommentsBlog` &tpl=`BlogTemplate` &paginate=`1` &alwaysshow=`1`]]
&startID shoud be the ID of this page, because newspublisher put all new articles on this page, and ditto will just read all and show them.
And that’s all...
CAUTION: Modx will show error if there is no blog articles, so, insert few articles before testing commenting...
This is a basic basics, form this point you can create better form (without unneccessary fields) also, you can use CSS to beautify results, etc...
With regards,
Ivan Mandic
Serbia
MODx playground: www.imandic.com