On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hello,

    Thanks for the fantastic work. I’m using Jot with placeholders to customize the arrangement of the different chunks. Currently, if there are no comments on a post, just the "Comments" header shows up with nothing underneath it. Is there a way to include a message like "No comments yet" in this case?

    Wanted to ask in case there was an option I was missing before I started digging in to a workaround involving a separate snippet and the comment count.


    • In ditto you can specify the &noResults tpl - I’m not going to look in the docs, but I am sure there is a similar function smiley
      • Hm...there’s a &tplComments parameter, but that controls the template for EACH comment, not for the comment block as a whole. I don’t see anything in the documentation about a "no comments" template. I’ll have to dig around in the snippet a bit more I guess.


        • There isn’t one.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
          • ouch!

            I see a feature request? laugh
            • Around line 434 of jot.class.inc.php, where it gets the comment count and assembles the comments, I threw in a little if/else statement that fills the "contents" variable with my preferred text if the count is 0. I would think we would just throw in another parameter and print its contents out there if it wasn’t empty.
              • Could you tell more indepth how to do this if/else?
                • Patching Jot’s core code for this simple purpose is groundless (it will make possible upgrade a nightmare). This is easily solved with such overlay to Jot:
                   JotExtNoComments Snippet written by http://setpro.net.pl/
                     id -> id of the document that Jot is bind to (default: current document)
                     jotChunk -> chunk that will be used for calling Jot when the document already has comments (required)
                     jotChunkNoComments -> chunk that will be used for calling Jot when the document has no comments so far (required)
                     [[JotExtNoComments? &jotChunk=`Comments` &jotChunkNoComments=`NoComments`]]
                  $jotChunk = isset($jotChunk) && $jotChunk ? $jotChunk : '<p class="error">You forgot to pass a chunk for calling Jot.</p>';
                  $jotChunkNoComments = isset($jotChunkNoComments) && $jotChunkNoComments ? $jotChunkNoComments : '<p class="error">You forgot to pass a chunk for calling Jot (no comments variant).</p>';
                  $jot_params = array(
                    'action' => 'count-comments',
                    'id' => (isset($id) && $id ? $id : $modx->documentObject['id'])
                  $count = $modx->runSnippet('Jot', $jot_params);
                  return $count ? $modx->getChunk($jotChunk) : $modx->getChunk($jotChunkNoComments);

                  If you remove my comments it will appear that it has just several lines of code, but this code will for sure survive possible upgrade with no further efforts. Tested.
                  • @alik: T H A N K Y O U ! cool
                      @hawproductions | http://mrhaw.com/

                      Infograph: MODX Advanced Install in 7 steps:

                      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    • Another thank you over here wink - just what I needed!