RenderBlogEntries
Render a set of postings to leaf through

02 May 2019 - 20:32 | Version 1 |

Documentation

This TopicFunction displays a collection of BlogEntries within the given CATegory and/or TAG.

Parameters
  • SKIP: offset into the archive
  • LIMIT: number of postings to show at max
  • CAT: categories to extract (optional)
  • TAG: tagged entries to be extracted (optional)
  • STICKY: a pattern the Sticky field must match to list the posting see the "Sticky" definition in Blog Entry (optional)
  • NOSTICKY: same as STICKY but with inverse logic
  • FROM_TIME: lower boundary of timespan to display in epoch seconds
  • TO_TIME: uppwer boundary of timespan to display in epoch seconds
  • ONLYTEASER: switch "on" to just render the teaser section; defaults to rendering the full posting

Implementation

%STARTINCLUDE%<!-- -->
<noautolink>
%DBQUERY{
  "TopicType=~'\bBlogEntry\b'
   AND State != 'unpublished'
   AND topic != 'WebTopicEditTemplate'
   %IF{"'%FROM_TIME{default=""}%' != ''" then="AND publishdate >= '%FROM_TIME%'"}%
   %IF{"'%TO_TIME{default=""}%' != ''" then="AND publishdate < '%TO_TIME%'"}%
   %IF{"'%CAT{default=""}%' != ''" then="AND topic ISA '%CAT%'"}%
   %IF{"'%TAG{default=""}%' != ''" then="AND Tag=~'\b%TAG%\b'"}%
   %IF{"'%STICKY{default=""}%' != ''" then="AND Sticky=~'\b%STICKY%\b'"}%
   %IF{"'%NOSTICKY{default=""}%' != ''" then="AND !(Sticky=~'\b%NOSTICKY%\b')"}%
  "
  limit="%LIMIT{default="5"}%" 
  skip="%SKIP{default="0"}%" 
  sort="publishdate" 
  reverse="on" 
  hidenull="on"
  web="%BASEWEB%" 
  header="%IF{"'%STICKY{default=""}%' != ''" then="<div class='blogEntriesSticky'>"}%"
  format="<div class='blogEntry'>
    <div class='foswikiTopicInfo'>
      <h1>
        <div class='blogCommentCount foswikiRight'>
        $percntDBCALL{\"Applications.BlogApp.RenderNumberOfComments\"
          THETOPIC=\"$web.$topic\"
          COMMENTSYSTEM=\"$expand(preferences.COMMENTSYSTEM or '%COMMENTSYSTEM{default="metacomment"}%')\"
        }$percnt</div>
        [[$web.$topic]] 
        $percntIF{\"'$expand(State)' = 'unpublished'\"
          then=\"<span class='foswikiAlert foswikiSmall'>(%TRANSLATE{"unpublished"}%)</span>\"
        }$percnt<!-- -->
        $percntREDDOT{\"$web.$topic\"}$percnt<!-- -->
        <div class='foswikiTopicSummary'>$expand(Summary')</div>
      </h1>
      %IF{"'%STICKY{default=""}%' = ''"  
         then="$percntDBCALL{\"%WEB%.%TOPIC%\" section=\"revinfo\"}$percnt" 
      }%<!-- -->
    </div>
    <div class='blogText hyphenate clearfix'>
$percntDBCALL{\"$web.$topic\" 
   $percntIF{\"'%ONLYTEASER{default="off"}%'='on' AND '$expand(_sections)'!=''\" 
      then=\"section=\\"teaser\\"\"
   }$percnt
}$percnt 
       <div class='blogMore'>[[$web.$topic][%TRANSLATE{"Read more"}%]]</div>
    </div>
    </div>"
   footer="%IF{"'%STICKY{default=""}%' != ''" then="</div>"}%
     $percntDBCALL{\"%WEB%.%TOPIC%\" 
       section=\"pagination%IF{"'%STICKY{default=""}%'!=''" then="DISABLED"}%\" 
       warn=\"off\"
       LIMIT=\"%LIMIT{default="5"}%\"  
       SKIP=\"%SKIP{default="0"}%\"  
       COUNT=\"$count\" 
       CLASS=\"blogBottomPagination\"
       PARAMS=\"%IF{
           "'%STICKY{default=""}%'!=''" then="&sticky=%STICKY%"
         }%%IF{
           "'%CAT{default=""}%'!=''" then="&catname=%CAT%"
         }%\"
     }$percnt<!-- -->"
}%<!-- -->
</pre>
</noautolink>
<!-- -->%STOPINCLUDE%

Revinfo

%STARTSECTION{"revinfo"}%%JQICON{"fa-calendar"}% <nop>$formatTime(publishdate)
<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"fa-user"}% $percntFORMATLIST{ 
   \"$expand(Author or createauthor)\"  
   split=\"\s*,\s*\"  
   format=\"$dollarpercntIF{\\"istopic '%USERSWEB%.$1'\\" then=\\"[[%USERSWEB%.$1]]\\" else=\\"<nop>$1\\"}$dollarpercnt\"  
   separator=\", \" 
}$percnt
$percntIF{\"'$expand(total_likes)'>0\"
   then=\"<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"fa-thumbs-o-up" class="fa-flip-horizontal"}% $expand(total_likes)\"
}$percnt<!-- -->
$percntCATINFO{
   topic=\"$web.$topic\"
   exclude=\"TopCategory\"
   header=\"<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"fa-folder"}% \"
}$percnt<!-- -->
$percntTAGINFO{
   topic=\"$web.$topic\"
   header=\"<span class='foswikiRevisionSep'>&#124;</span> %JQICON{"fa-tag"}% \"
}$percnt<!-- -->%ENDSECTION{"revinfo"}%

Pagination

%STARTSECTION{"pagination"}%<!-- -->
%CALCULATE{"$SET(theNextSkip,$EVAL($VALUE(%SKIP{default="0"}%)+$VALUE(%LIMIT{default="5"}%)))$SET(thePrevSkip,$EVAL($VALUE(%SKIP{default="0"}%)-$VALUE(%LIMIT{default="5}%)))$IF($GET(thePrevSkip) < 0,$SET(thePrevSkip,0))"}%<!-- -->
<div class='blogPagination foswikiSmallish foswikiHideOnPrint clearfix %CLASS{default=""}%'> 
<div class='blogPrev' %IF{"%SKIP{default="0"}% = 0" then="style='display:none'"}%> 
<a href='%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?skip=%CALCULATE{"$GET(thePrevSkip)"}%&limit=%LIMIT{default="5"}%%PARAMS{default=""}%'>%TRANSLATE{"previous page"}%</a> 
</div> 
<div class='blogNext' %IF{"%CALCULATE{"$GET(theNextSkip)"}% >= %COUNT%" then="style='display:none'"}%>
<a href='%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?skip=%CALCULATE{"$GET(theNextSkip)"}%&limit=%LIMIT{default="5"}%%PARAMS{default=""}%'>%TRANSLATE{"next page"}%</a> 
</div> 
</div><!-- -->%ENDSECTION{"pagination"}%

Test

no stickiness

stickiness

Calls to 'RenderBlogEntries'

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.
Uploading ...
Drag files here.