We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2912
    • 315 Posts
    Hi All,

    I have been playing around with the Jot code to allow for a new parameter for excluding documents.

    Here is what I have but it would be nice if someone could check it to see if it works for them and everyone.

    jot.snippet.txt
    Change 1
    Add the following
    $Jot->Set("excludedocs",$excludedocs);
    

    after
    $Jot->Set("docid", $docid);
    


    jot.class.inc.php
    Change 2
    Add the following
    $this->config["excludedocs"] = !is_null($this->Get("excludedocs")) ? $this->Get("excludedocs"): "";
    

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


    Change 3
    Change the following line from
    $array_comments = $this->provider->GetComments($this->config["docid"],$this->config["tagid"],$view,$this->config["sortby"],$pageOffset,$pageLength);
    

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


    Change 4
    Change the following line
    return $this->provider->GetCommentCount($this->config["docid"],$this->config["tagid"],$view);
    

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


    jot.db.class.inc.php
    Change 5
    Change the following line
    function GetCommentCount($docid,$tagid,$viewtype) {
    

    To
    function GetCommentCount($docid,$tagid,$viewtype,$excludedocs) {
    


    Change 6
    Change the following in the function GetCommentCount
    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
    		}
    

    To
    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
    		}
    		
    		if ($excludedocs) {
    			$excdoc = explode(",", $excludedocs);
    			foreach ($excdoc as $value) {
    				$where .= " and uparent != '".$value."'";
    			}
    		}
    

    (Basically add the extra three lines after the switch call.)

    Change 7
    Change the following line
    function GetComments($docid,$tagid,$viewtype,$sort,$offset,$length) {
    

    To
    function GetComments($docid,$tagid,$viewtype,$sort,$offset,$length,$excludedocs) {
    


    Change 8
    (Same as Change 6)
    Change the following in the function GetCommentCount
    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
    		}
    

    To
    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
    		}
    		
    		if ($excludedocs) {
    			$excdoc = explode(",", $excludedocs);
    			foreach ($excdoc as $value) {
    				$where .= " and uparent != '".$value."'";
    			}
    		}
    

    (Basically add the extra three lines after the switch call.)

    I have already modified my code to use the docid=`*` parameter but I’m hoping that this covers everything I have changed in getting it to work.

    Here’s it working on my development site

    I have multiple pages allowing for comments but the two main pages work as follows.

    Movie Comments Lists all the comments from Jot using the new parameter "excludedocs" to remove comments posted in Wise Words

    Wise words was done to allow for simple quotes that are displayed in the bottom right hand corner of the site (randomly picked from what is posted by users).

    Hope I’ve explained it well enough! smiley

    Modified above code to allow for multiple excluded documents.
      BBloke
      • 2912
      • 315 Posts
      I modified the above code to allow for more than one exclusion.
        BBloke