%META:TOPICINFO{author="TWikiContributor" date="1141827377" format="1.1" version="1.1"}%
%META:TOPICPARENT{name="TopicFunction"}%
---+!! Function: %TOPIC%
%FORMFIELD{"TopicDescription"}%

---++ Parameters
   * QUERY: the item to be searched for in the archive

---++ Implementation
<verbatim>
%STARTINCLUDE%
*~~
%STOPALIASAREA%
<noautolink>
*~~
<div class="blogArchiveDateSelect">
<div class="blogArchiveYears">
%~~ DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published'
~~~   %IFDEFINED{"%URLPARAM{"year"}%" then="AND Date=~'$test'" glue="off"}%
~~~   "
~~~   field="Date" sort="created" 
~~~   pattern="(\d\d\d\d)"
~~~   format="
~~~     <span class=\"blogArchiveYear\">
~~~       <a href=\"%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?mode=chron;year=$key\"
~~~          class=\"$percntCALC{\"$IF($EXACT(%URLPARAM{"year"}%,$key),current)\"}$percnt\"
~~~       >$key</a>
~~~     </span>"
~~~ }%
</div>
<div class="blogArchiveMonths">
%~~ DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published'
~~~   %IFDEFINED{"%URLPARAM{"year"}%" then="AND Date=~'$test'" glue="off"}%
~~~   %IFDEFINED{"%URLPARAM{"month"}%" then="AND Date=~'$test'" glue="off"}%
~~~   "
~~~   field="Date" sort="created" 
~~~   pattern="(\w+) \d\d\d\d"
~~~   format="
~~~     <span class=\"blogArchiveMonth\">
~~~       <a href=\"%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%?
*~~          mode=chron;month=$key;year=%URLPARAM{"year" default=".*"}%\"
~~~          class=\"$percntCALC{\"$IF($EXACT(%URLPARAM{"month"}%,$key),current)\"}$percnt\"
~~~       >$key</a>
~~~     </span>"
~~~ }%
</div>
</div>
%~~ DBCALL{"RenderBlogArchiveHitList" 
~~~   QUERY="
*~~    %IFDEFINED{"%URLPARAM{"year"}%" then="AND Date=~'$test'" glue="off"}%
~~~    %IFDEFINED{"%URLPARAM{"month"}%" then="AND Date=~'$test'" glue="off"}%
*~~   "
~~~   PARAMS="
*~~     mode=chron;
*~~     month=%URLPARAM{"month" default=".*"}%;
*~~     year=%URLPARAM{"year" default=".*"}%
*~~   "
~~~ }%
*~~
</noautolink>
%STARTALIASAREA%
*~~
%STOPINCLUDE%
</verbatim>

<!-- interrupt glue -->

---++ Test
See BlogArchive


%DBCALL{"RenderFunctionCallers"}%

<!--
   * Set ALLOWTOPICCHANGE = %MAINWEB%.BlogAdminGroup
   * Set SIDEBAR = Admin
   * Set SIDEBARARG = TopicFunction
-->


%META:FORM{name="TopicForm"}%
%META:FIELD{name="TopicType" attributes="M" title="TopicType" value="TopicFunction"}%
%META:FIELD{name="TopicDescription" attributes="M" title="TopicDescription" value="Renders the BlogArchive in CHRON mode"}%
