We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4429
    • 429 Posts
    I have successfully managed to get jot to show latests comments on the front page of my site(it took a few hacks). How do i limit its output to comments of a particular parent only?

    Would &parent or &startID work with jot? Neither of these are documented in the Jot wiki.

    My call is;

    [!Jot? &placeholders=`1` &output=`0` &tplComments=`latest_tpl` &sortby=`createdon:d`  &pagination=`2`  &tplNav=``     &css=`0` &docid=`*` !]
      • 4041
      • 788 Posts
      Try changing &docid=`*`, change the * to the document id that holds the comments you want to show.
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 4429
        • 429 Posts
        That will work but really I wanted to be able to put in a parent.

        The reason being its that I about 20 article catagories, each containing a number of articles with comments. I’d rather not have to manually put in each article in the &docid.

        As you could imagine, doing it this was I could end up with a &doc looking like

        &docid=`4,5,6,7,8,9,10,11,12,13,14,15,15,17,33,34,35,36,45,46,48,49`
          • 4041
          • 788 Posts
          I cobbled together a quick snippet which aggregates the comments, very basic but it works. Perhaps it can give you a start point.

          Create a new snippet with the code below.
          Call it in the page uncached ( [! !] )
          If you don’t set a &parentid, it uses the currrent document.
          Then it figures out the published children, then runs the Jot snippet for each document accordingly.

          Your Jot params are set in the $jparams array, it’s easy to figure out the format using the example.

          Caveats: Using pagination, there is a set of paging links above and below each section of comments.

          <?php
          /*      jotgroup snippet
                  [!jotgroup!]
                  [!jotgroup? &parentid=`` &comlimit=``!]
          
          */
          $output ='';
          $parentid = isset($parentid) ? intval($parentid) : $modx->documentIdentifier;
          $comlimit = isset($comlimit) ? intval($comlimit) : '2';
          
              $d = "SELECT * FROM ".$modx->getFullTableName( 'site_content' )." WHERE parent='".$parentid."' and published='1'";
              $d2 = $modx->db->query($d);
              $d3 = $modx->recordCount($d2);
          
              if($d3 > 0){
          
                while($pid = $modx->fetchRow($d2)){
                  
                      $dj = "SELECT * FROM ".$modx->getFullTableName( 'jot_content' )." WHERE uparent='".$pid['id']."'";
                      $dj2 = $modx->db->query($dj);
                      $dj3 = $modx->recordCount($dj2);
          
                         if($dj3 > 0){
          
                         //$output .='<p><h3><a href="[~'.$pid['id'].'~]">'.$pid['pagetitle'].'</a></h3></p>';
                     
                             // set up your required Jot params here
                             $jparams =array(
                                 'action'         => 'comments',
                                 'docid'          =>$pid['id'],
                                 'pagination'     =>$comlimit
                             );
                             
                             $output .= $modx->runSnippet('Jot', $jparams);
                             //$output .='<p><b>'.$dj3.'</b> records found<hr></p>';
                         }
                  }
                  
              }else{
                 $output .='<p>nothing found</p>';
              }
          
          return $output;
          ?>


          Hope this helps.
            xforum
            http://frsbuilders.net (under construction) forum for evolution