We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    Hi all,
    Is there a way to display the comments count of all child docs of certain container?
    currently if I specify doc ID it counts only for that doc id without going deeper.


      • 33337
      • 3,975 Posts
      I believe there is nothing available yet, but something can be written to achieve this.
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 33992 ☆ A M B ☆
        • 455 Posts
        if the children IDs are specified, I guess it is possible to somthing like this:
        [+phx:math:[!Jot?action=`count-comments`&docid=`10`!]+[!Jot?action=`count-comments`&docid=`11`!]+[!Jot?action=`count-comments`&docid=`10`!][!Jot?action=`count-comments`&docid=`12`!]....+]


        and you could create a simple snippet like this:
        <?php
        $parent = isset($parent) ? $parent : null;
        if($parent)
        {
        	$sql = '
        		SELECT COUNT(jot.id) FROM ' .$modx->getFullTableName('jot_content'). ' jot 
        		INNER JOIN ' .$modx->getFullTableName('site_content'). ' sc 
        		WHERE jot.uparent=sc.id AND sc.parent=' .$parent;
        	$select = $modx->db->query($sql);
        	
        	if($modx->db->getRecordCount($select) == 0)
        		return "0";
        	
        	return $modx->db->getValue($select);
        }
        ?>
          God loves me. 【ツ】


          MODX.ir (Persian Support)

          Boplo.ir/modx/ (Persian)
          • 27330
          • 884 Posts
          that’s great. thank you very much. work out of the box smiley
            • 33992 ☆ A M B ☆
            • 455 Posts
            You are welcome!

            Another way, CakeMODx grin grin
            <?php
            if($parent)
            {
            	include "CakeMODx.class.php";
            	$CakeMODx = new CakeMODx;
            	return $CakeMODx->commentCount_byDoc($parent);
            }
            ?>
              God loves me. 【ツ】


              MODX.ir (Persian Support)

              Boplo.ir/modx/ (Persian)