RenderRecentComments
display a list of recent comments in the current web

28 January 2025 - 14:54 | Version 1 |

Documentation

This function is used to render a section in a sidebar listing the recent comments last month limitted to a max of 10 by default. To fetch the list of most recent comments there are two implementations below: one using DBQUERY and METACOMMENT and the other using SOLRSEARCH. The latter is used automatically when SolrPlugin is installed.

Parameters
  • THEWEB: web to search for comments, defaults to %BASEWEB%
  • LIMIT: max number of comments to show
  • CAT: retrieve recent comments on BlogEntries in that category
  • MONTHS: age of comments to display by number of months, defaults to 1

Implementation

%STARTINCLUDE%<noautolink>
%DBQUERY{
  "1 %IF{
      "'%EXPAND{"$percntCOMMENTMODERATION$percnt" scope="%THEWEB{default="%BASEWEB%"}%.WebPreferences"}%'='on'"
      then="AND state!='unapproved'"
  }% %IF{"'%MONTHS{default="1"}%'!='0'"
      then="AND modified >= $percntDATETIME{delta=\"%MONTHS{default="1"}% month ago\" lang=\"en\" format=\"$epoch\"}$percnt"
  }%"
  topics="%DBQUERY{
      "State='published' AND (preferences.COMMENTMODERATION!='on' OR state!='unapproved') 
      %IF{"'%CAT{default=""}%'!=''" then="AND topic ISA '%CAT%'"}%"
      web="%THEWEB{default="%BASEWEB%"}%" 
      format="$topic"
      separator=", "
  }%"
  web="%THEWEB{default="%BASEWEB%"}%" 
  context="comment"
  sort="modified"
  reverse="on"
  hidenull="on"
  limit="%LIMIT{default="10"}%"
  header="<div class='blogSideBarSection'>
    <h2 >%IF{"'%CAT{default=""}%'!=''"
        then="%TRANSLATE{"Comments in [_1]" args="%CATINFO{cat="%CAT%" format="$title"}%"}%"
        else="%TRANSLATE{"Comments"}%"
      }%</h2>
    <ul>"
  format="<li>
     <a href='$percntSCRIPTURLPATH{\"view\" topic=\"$web.$topic\"}$percnt#comment$expand(name)'>
       $percntTMPL:P{\"comment::photo\"
         web=\"%USERSWEB%\"
         topic=\"$expand(author)\"
         align=\"right\"
       }$percnt
       $percntTRANSLATE{\"[_1] replied on [_2] [_3]\" 
          arg1=\"<b>$percntGETTOPICTITLE{\"%USERSWEB%.$expand(author)\"}$percnt</b>\"
          arg2=\"&#147;$percntGETTOPICTITLE{\"$web.$topic\" encode=\"entity\"}$percnt&#148;\"
          arg3=\"$formatTime(modified, '%E %B %Y')\"
       }$percnt
       %CLEAR%
     </a>
     </li>"
  footer="</ul></div>"
  separator="$n"
}%<!-- -->
</noautolink>%STOPINCLUDE%

Test

Calls to 'RenderRecentComments'

Copyright

© 2005-2025 Michael Daum

This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. For more details read the LICENSE.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding arbeitsgruppe.ch? Send feedback