We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3004
    • 21 Posts
    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.

    Thanks,

    Aaron
      • 10226
      • 412 Posts
      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
        • 3004
        • 21 Posts
        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.

        Thanks,

        Aaron
        • 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
            • 10226
            • 412 Posts
            ouch!

            I see a feature request? laugh
              • 3004
              • 21 Posts
              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.
                • 28849
                • 9 Posts
                Could you tell more indepth how to do this if/else?
                  • 1122
                  • 209 Posts
                  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:
                  <?php
                  /* 
                   JotExtNoComments Snippet written by http://setpro.net.pl/
                   Parameters:
                     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)
                   Example:
                     [[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.
                    • 20413
                    • 2,877 Posts
                    @alik: T H A N K Y O U ! cool
                      @hawproductions | http://mrhaw.com/

                      Infograph: MODX Advanced Install in 7 steps:
                      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                      • 17412
                      • 270 Posts
                      Another thank you over here wink - just what I needed!