=====""ShowComments"" Handler===== >>==See also:== Documentation: ShowCommentsHandlerInfo.>>This is the development page for the ""ShowComments"" handler.::c:: ""ShowComments"" handler let you to see a page containing only the comments. It is useful if, as example, a page is really long and is long to load, too many content or too slow connection. If you want to see the comments, you don't want to wait the page to load, especially when there are many comments page (paged comments). I'm sure of this : **This handler can be improved**. Now, the code : %%(php) LoadComments($this->tag)); // calculate starting item of last page $lastcomments = ceil($n/$d)*$d; $start = ($n > $d)? ($lastcomments-$d) : "0"; // set starting item and limit $s = (isset($_REQUEST["s"]))? $_REQUEST["s"] : $start; $l = (isset($_REQUEST["l"]))? $_REQUEST["l"] : $d; // set no limits for showall visualization if ($showall == 1) { $s = "0"; $l = "999"; } // Build pager links: // FLAVOUR B) - pagelist if ($showall == 0 && $n > $l) { $i = 0; while ($i < $n) { if ($i == $s) { $pager .= ($i+1)."-".($i+$l)." | \n"; } else { $pager .= "Href("showcomments","","l=".$l."&s=".($i))."\">".($i+1)."-".($i + $l)." | \n"; } $i = $i + $l; } } // create switcher link switch($showall) { case "0": $switcher = ($n > $l)? " Href("showcomments","","showall=1")."\">all " : ""; break; case "1": $switcher = ($n > $d)? " Href("showcomments","","showall=0")."\">show paged " : ""; } // load comments for this page with limits $comments = $this->LoadCommentPage($this->tag, $s, $l); // store comments display in session $tag = $this->GetPageTag(); if (!isset($_SESSION["show_comments"][$tag])) $_SESSION["show_comments"][$tag] = ($this->UserWantsComments() ? "1" : "0"); if (isset($_REQUEST["show_comments"])){ switch($_REQUEST["show_comments"]) { case "0": $_SESSION["show_comments"][$tag] = 0; break; case "1": $_SESSION["show_comments"][$tag] = 1; break; } } // display comments! // display comments header ?>
 Comments
GetUserName(); foreach ($comments as $comment) { print("
\n"); print("".$comment["comment"]."\n"); print("\t
\n-- ".$this->Format($comment["user"])." (".$comment["time"].")\n"); $current_user = $this->GetUserName(); if ($this->UserIsOwner() || $current_user == $comment["user"] || ($this->config['anony_delete_own_comments'] && $current_user == $comment["user"]) ) { ?> FormOpen("delcomment"); ?> " /> FormClose(); ?> \n"); print("
\n"); } // Show bottom pager link if ($showall == 0 && $n > $l) { print "
".$pager.$switcher."
\n"; } } // display comment form print("
\n"); if ($this->HasAccess("comment")) {?> FormOpen("addcomment"); ?> FormClose(); ?> \n"); ?> %% And finally, to make it redirect back on the handler's page, when posting a new comment : modify pages/addcomment.php FIND : %%(php) // redirect to page $this->redirect($this->Href(), $redirectmessage); %% Replace with : %%(php) if ($_POST['from'] == 'showcomments') { $href = $this->Href().'/showcomments'; } else { $href = $this->Href(); } // redirect to page $this->redirect($href, $redirectmessage); %% If there is any issue or bug, comment and correct it. As usual. ---- CategoryDevelopment