We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    I needed to display comments from several documents too and I’m using Jot 1.1.3
    The following changes allow &docids=`120,155,156...` or something like &docids=`[[get_all_documents_I_want]]` to work.

    in Jot-snippet add:
    $Jot->Set("docids", $docids);


    In assets/snippets/jot/jot.class.inc.php, add
    $this->config["docids"] = !is_null($this->Get("docids")) ? explode(',',$this->Get("docids")):explode(',',$this->config["docid"]);

    and replace
    $array_comments = $this->provider->GetComments($this->config["docid"],$this->config["tagid"],$view,$this->config["sortby"],$pageOffset,$pageLength);

    with
    $array_comments = $this->provider->GetComments($this->config["docids"],$this->config["tagid"],$view,$this->config["sortby"],$pageOffset,$pageLength);	

    and
    return $this->provider->GetCommentCount($this->config["docid"],$this->config["tagid"],$view);

    with
    return $this->provider->GetCommentCount($this->config["docids"],$this->config["tagid"],$view);

    In assets/snippets/jot/includes/jot.db.class.inc.php
    In function GetCommentCount, change
    $sql = 'SELECT count(id) FROM '.$this->tbl["content"].' WHERE uparent = '.$docid.' AND tagid = "' . $tagid .'"'.$where;

    with
    $where.=' and (false';
    foreach ($docid as $did){
    $where.= ' or uparent = '.$did;
    }		
    $where.=')';
    $sql = 'SELECT count(id) FROM '.$this->tbl["content"].' WHERE tagid = "' . $tagid .'"'.$where;

    and in function GetComments, change
    $sql = "select a.* from " . $tbl . " as a " . $tblcustom . " where uparent = '" . $docid . "' and tagid = '" . $tagid ."' and mode = '0' " . $where . $orderby . $limit;

    with
    $where.=' and ( false';
    foreach ($docid as $did){
    $where.= ' or uparent = '.$did;
    }		
    $where.=')';
    $sql = "select a.* from " . $tbl . " as a " . $tblcustom . " where tagid = '" . $tagid ."' and mode = '0' " . $where . $orderby . $limit;



      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 24027
      • 31 Posts
      Hello,

      Does it work with the new release (1.4.4) ?
        • 1978
        • 131 Posts
        Just downloaded 1.4.4 and * doesnt work sad
        is there any SVN download?
          Как русифировать Modx 0.9.6.1(QuickEdit, TinyMCE)
          QuickEdit под win-1251 без mb_-функций
          • 7070
          • 1 Posts
          Hey Rachel, Thanks for the hack, it’s Great!

          I was wondering if anyone could help me...

          what’s being returned is a listing of all comments, even if the comment is supposed to be unpublished or if the comment is redundant because their parent document is unpublished

          I need a way to hide comments that are (1) made against unpublished documents and comments that (2) have been unpublished/deleted

          II have a hunch that using PHx in the Jot template might be the way to go but I’m a bit of a rookie and I’m stuck there... any help would be appreciated.

          Cheers

          D
          • I just modified the code provided by Rafael to make Jot 1.1.4 show the 10 last comments but only if the documents are published.

            replace:

            $this->config["docid"] = !is_null($this->Get("docid")) ? intval($this->Get("docid")):$modx->documentIdentifier;
            


            with

            if (!is_null($this->Get("docid")) && ($this->Get("docid") == '*'))
            		$this->config["docid"] = '*';
            	else
            		$this->config["docid"] = !is_null($this->Get("docid")) ? intval($this->Get("docid")):$modx->documentIdentifier;
            


            In assets/snippets/jot/includes/jot.db.class.inc.php
            In function GetCommentCount, change

            $sql = 'SELECT count(id) FROM '.$this->tbl["content"].' WHERE uparent = '.$docid.' AND tagid = "' . $tagid .'"'.$where;
            


            with

            if ($docid == '*')
            		$sql = 'SELECT count(id) FROM '.$this->tbl["content"].' WHERE tagid = "' . $tagid .'"'.$where;
            	else
            		$sql = 'SELECT count(id) FROM '.$this->tbl["content"].' WHERE uparent = '.$docid.' AND tagid = "' . $tagid .'"'.$where;
            


            in function GetComments, change

            switch ($viewtype) {
            			case 2:
            					$where = " and published >= 0 "; // Mixed
            				break;
            			case 0:
            
            					$where = " and published >= 0 "; // Unpublished
            				break;
            			case 1:
            			default:
            				$where = " and published = 1 "; // Published
            		}
            


            with

            		switch ($viewtype) {
            			case 2:
            				$where = " and a.published >= 0 "; // Mixed
            				break;
            			case 0:
            				$where = " and a.published >= 0 "; // Unpublished
            				break;
            			case 1:
            			default:
            				$where = " and a.published = 1 "; // Published
            		}
            


            and

            $sql = "select a.* from " . $tbl . " as a " . $tblcustom . " where uparent = '" . $docid . "' and tagid = '" . $tagid ."' and mode = '0' " . $where . $orderby . $limit;
            


            with

            if ($docid == '*')
            			$sql = "select a.*, b.published AS docpublished from " . $tbl . " as a " . $tblcustom . " 
            					left join modx_site_content AS b ON a.uparent = b.id 
            					where tagid = '" . $tagid ."' and mode = '0' and b.published='1' " . $where . $orderby . $limit;
            		else
            			$sql = "select a.* from " . $tbl . " as a " . $tblcustom . " where uparent = '$docid' and tagid = '" . $tagid ."' and mode = '0' " . $where . $orderby . $limit;
            



            Hope it helps!
              • 25483
              • 741 Posts
              Does anyone have this working with Jot 1.1.4? I tried the changes from the latest post, but I don’t get any comments when I use it.
                with regards,

                Ronald Lokers
                'Front-end developer' @ h2o Media

                • 37514
                • 178 Posts
                Just a question, can Jot be used in this way to link the comment back to its parent document?
                  • 23183
                  • 102 Posts
                  Quote from: JimKillock at Oct 07, 2009, 06:29 PM

                  Just a question, can Jot be used in this way to link the comment back to its parent document?

                  Yes it can.

                  Is there a way on 1.1.4 to allow multiple docId’s to be input? Tried Bruno17’s code changes but no luck sad
                    • 23183
                    • 102 Posts
                    Sorry to bump this but gas anyone succesfully managed to add multiple docIds to the call when using Jot version 1.1.4? Anyone point me in the right direction to find out how to do it, would be very useful if I could get it working

                    Thanks
                      • 28159
                      • 22 Posts
                      I was able to get this working with Jot 1.1.4 using Rachel’s hacks a few posts up. No problems at all.

                      [Edit:]

                      By the way, by default with Rachel’s hack, it still adds pagination. So, if you want the latest 5 comments and you have more than 5, you’ll have the standard "Page 1 of 4" navigation appear.

                      If you don’t want this (you only want the latest 5, without the pagination), just add this to your Jot call:

                      &tplNav=``

                      That replaces the default pagination template with a blank string, and thus the pagination doesn’t appear.