RenderRecentNews

28 January 2025 - 14:54 | Version 1 |

Documentation

This function renders a list of recent BlogEntries in the given web. Only published postings will be rendered as well as those not tagged "blogonly". Each posting's teaser will be extracted.

See also:

Parameters
  • SKIP: number of items to skip, default 0
  • LIMIT: number of items to show, default 4
  • THEWEB: web holding blog entries, default Blog
  • CAT: categories to extract (optional)
  • TAG: tagged entries to be extracted (optional)
  • SHOWREVINFO: on/off, default on
  • STICKY

Implementation

%STARTINCLUDE%<noautolink>%DBQUERY{
  "TopicType=~'\bBlogEntry\b' AND State='published' AND Tag!~'\bblogonly\b'
   %IF{"'%CAT{default=""}%' != ''" 
      then=" AND topic ISA '%CAT%'"
   }%%IF{"'%TAG{default=""}%' != ''" 
      then=" AND Tag=~'\b%TAG%\b'"
   }%%IF{"'%STICKY{default="foobar"}%' != 'foobar'" 
      then=" AND Sticky=~'\b%STICKY%\b'"
  }% AND (preferences.CONTENT_LANGUAGE='%LANGUAGE%' OR ('%LANGUAGE%'='%DEFAULTLANGUAGE%' AND !preferences.CONTENT_LANGUAGE))"
  exclude="WebTopicEditTemplate"
  web="%THEWEB{default="Blog"}%" 
  sort="publishdate"
  %IF{"'%STICKY{default=""}%' != ''" 
    then="header=\"<div class='blogEntriesSticky'>\" footer=\"</div>\""
  }%
  format="<div class='blogEntry clearfix'>
   <div class='foswikiTopicInfo'>
   <h2>[[$web.$topic]]
      <div class='foswikiTopicSummary'>$expand(Summary)</div>
   </h2>
   %IF{"'%SHOWREVINFO{default="on"}%'='on'"
      then="$dollarpercntDBCALL{\\"%WEB%.%TOPIC%\\" section=\\"revinfo\\" web=\\"$web\\" topic=\\"$topic\\"}$dollarpercnt"
   }%</div>
   <div class='blogText hyphenate clearfix'>
$percntDBCALL{\"$web.$topic\" section=\"teaser\" warn=\"off\"}$percnt<!-- -->
   </div>
   <div class='blogMore'>[[$percntIF{\"'$expand(TargetPage)'\" then=\"$expand(TargetPage)\" else=\"$web.$topic\"}$percnt][%TRANSLATE{"Read more"}%]]</div>
  </div>"
  separator="$n"
  limit="%LIMIT{default="4"}%"
  skip="%SKIP{default="0"}%"
  reverse="on"
  hidenull="on"
}%%ADDTOZONE{"head"
  id="BLOGPLUGIN::CSS"
  text="<link rel='stylesheet' href='%PUBURLPATH%/%SYSTEMWEB%/BlogPlugin/build/blogplugin.css'  media='all' />"
}%<style>
.blogEntry h2 {
  border-bottom:1px solid var(--color-border);
}
.blogEntry h2,
.blogEntry h2 a {
   color:var(--color-h2);
}
.blogEntry .blogMore {
   margin-top:var(--margin);
}
</style>
</noautolink>%STOPINCLUDE%

Revision Info

%STARTSECTION{"revinfo"}%<div class="foswikiRevision blogInfo"> 
  %DBQUERY{ 
    web="%web%"
    topic="%topic%"  
    format="%JQICON{"ma-calendar-month"}% <span itemprop='datePublished' content='$formatTime(publishdate, '$year-$mo-$day')'>$formatTime(publishdate)</span> 
      <span class='foswikiRevisionSep'>&#124;</span> %JQICON{"ma-person"}% $percntFORMATLIST{ 
      \"$expand(Author or createauthor)\"  
      split=\"\s*,\s*\"  
      format=\"$dollarpercntIF{\\"istopic '%USERSWEB%.$1'\\" then=\\"<a href='$dollarpercntSCRIPTURLPATH{\\"view\\" topic=\\"%USERSWEB%.$1\\"}$dollarpercnt' rel='author' itemprop='author' class='foswikiUserField' data-wiki-name='$1'>$dollarpercntGETTOPICTITLE{%USERSWEB%.$1}$dollarpercnt</a>\\" else=\\"<nop>$1\\"}$dollarpercnt\"  
      separator=\", \" 
    }$percnt
    $percntIF{\"'$expand(total_likes)'>0\"
       then=\"<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"ma-thumb-up"}% $expand(total_likes)\"
    }$percnt $percntIF{\"'$expand(comment[])'!=''\"
       then=\"<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"fa-comment"}% $expand(comment[])\"
    }$percnt<!-- -->"
  }% 
  %CATINFO{ 
    "%web%.%topic%"  
    exclude="TopCategory"
    header="<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"fa-folder"}% " 
    format="<a href='$url' rel='tag' itemprop='keywords' class='$name'>$title</a>" 
  }% <!-- --> 
  %TAGINFO{ 
    "%web%.%topic%" 
    header="<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"fa-tag"}% " 
    format="<a href='$url' rel='tag' itemprop='keywords' class='$class'>$name</a>" 
  }% <!-- --> 
</div>%ENDSECTION{"revinfo"}%

Test

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