We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12808
    • 70 Posts
    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
      --
      www.spotkg.com
      • 25322
      • 78 Posts
      thanks for this imandic. its really helped me out.. i am newbie to all this.
      A couple of questions..
      The document you have created to show the blog articles :show_blog . if i wanted the articles to show up inside a div on my homepage do i just put
      [[Ditto? &startID=`43` &summarize=`2` &total=`20` &commentschunk=`CommentsBlog` &tpl=`BlogTemplate` &paginate=`1` &alwaysshow=`1`]]

      inside this div and change the startID to what ever id my home-page is.. should this work ok.
      also
      Most times if i submit a post, it won’t show up on my blog until i do something like delete another post. why would this happen? should my post not come up immediately
        • 2472
        • 151 Posts
        Quote from: rob21 at Feb 04, 2007, 09:07 AM

        ...
        Most times if i submit a post, it won’t show up on my blog until i do something like delete another post. why would this happen? should my post not come up immediately


        Guess you have to call Ditto uncached using [!Ditto... !] instead of [[...]].

        Snippets that extract data from the database should always be called uncached if you want to see the newest data...
          A thing of beauty is a joy forever ( John Keats)
          • 25322
          • 78 Posts
          cheers for the reply... yeah if i call ditto uncached then the posts that i am waiting for come up on the blog. I get an error for the count  comments though. Comments ([!Jot?&docid=`54`&action=`count-comments`!])   
          Even still when i write a new post it doesn’t update immediately. Any other suggestions

          How do i get the new pages that are created for each blog post to have a certain template attached to them?

            • 7923
            • 4,213 Posts
            Currently the modx parser can’t handle snippet calls inside snippet call that are on the same cache level.

            So if you call [!Ditto..!] then in Ditto’s chunk use [[Jot..]], or vice verse. Or call everything [[cached]] and set the document to be not cacheable.


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 25322
              • 78 Posts
              cheers. i’ll figure it out.
                • 25322
                • 78 Posts
                How would i go about making the input blog page only accessible to the administrator?
                  • 25322
                  • 78 Posts
                  How would i go about creating an rss feed of this blog?
                    • 25663 MODX Staff
                    • 12,272 Posts
                    Thanks for this Tutorial. smiley

                    When a few more details are ironed out I hope someone will move it to the wiki. In the interim, this definitely belongs in our new MODx 101 forum as it touches on a lot of how MODx works ... thanks again!

                    (Moving there now and making it a sticky topic)
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 19554
                      • 59 Posts
                      Ivan, I just copied yout tutorial to wiki (http://wiki.modxcms.com/index.php/Basic_Blog).
                      It would be nice if we could expand and polish this example enough so it can become part of default template that comes with ModX installation.
                      So, everyone, please apply all your improvements to wiki article.

                      P.S. I will also make some reformatting during the evening....