RenderRecentComments
display a list of recent comments in the current web

02 May 2019 - 20:32 | 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
  • 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>
%METACOMMENTS{
  web="%BASEWEB%" 
  topic="%HOMETOPIC%"
  search="State!='unpublished' %IF{"defined CAT and '%CAT%'!=''" then="AND topic ISA '%CAT%'"}%"
  sort="date"
  reverse="on"
  approved="on"
  mindate="%DATETIME{delta="%MONTHS{default="1"}% month ago" lang="en"}%"
  limit="%LIMIT{default="10"}%"
  header="<div class='blogSideBarSection'>
    <h2 >%IF{"defined CAT and '%CAT%'!=''"
        then="%TRANSLATE{"Comments in [_1]" args="%CATINFO{cat="%CAT%" format="$title"}%"}%"
        else="%TRANSLATE{"Comments"}%"
      }%</h2>
    <ul>"
  format="<li>
     <a href='$permlink'>
       $percntTMPL:P{\"comment::photo\"
         web=\"%USERSWEB%\"
         topic=\"$author\"
         align=\"right\"
       }$percnt
       $percntTRANSLATE{\"[_1] replied on [_2] [_3]\" 
          args=\"<strong>$percntSPACEOUT{$author}$percnt</strong>, &#147;$percntGETTOPICTITLE{\"$web.$topic\" encode=\"entity\"}$percnt&#148;,  $percntCALCULATE{\"$FORMATTIME($timestamp, $day&&nbsp;$mon&&nbsp;$year)\"}$percnt\"
       }$percnt
       %CLEAR%
     </a>
     </li>"
  footer="</ul></div>"
  separator="$n"
}%<!-- -->
</noautolink>%STOPINCLUDE%

Test

Calls to 'RenderRecentComments'

Copyright

© 2005-2019 http://michaeldaumconsulting.com

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.