[Solved] CGBlog archive view by year

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
onninen
New Member
New Member
Posts: 8
Joined: Sat Jun 19, 2010 8:10 pm

[Solved] CGBlog archive view by year

Post by onninen »

Current default archive template produces list by monthly. This will generate long list if there is already blog articles from many years. See http://www.ikivihrea.com/blogi

How do I create following archive view?

-current year 2011 displayed monthly as by default design
-2010 (if year is clicked will show beneath 2010 blog articles by monthly)
-2009 (if year is clicked will show beneath 2009 blog articles by monthly)

Any help appreciated!
Thanks!
Last edited by onninen on Wed Mar 14, 2012 6:56 pm, edited 1 time in total.
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am
Location: The Netherlands

Re: CGBlog archive view by year

Post by Gregor »

On your site I saw your working solution. Would you be so kind to post your solution?

Thanks in advance,
Gregor
onninen
New Member
New Member
Posts: 8
Joined: Sat Jun 19, 2010 8:10 pm

Re: CGBlog archive view by year

Post by onninen »

Here is the solution. It's not so elegant, but works.
I did it so that I made past years' monthly blog links manually. Then I modified blog archive view code way it shows current year only. I installed jQuery module 1.1.3 and used jQuery for hiding/unhiding year's monthly blogs, when specific year is clicked.

The code:
Page's html code

{CGBlog action='archive' lang="fi_FI"}

<p class="shtitle"><span style="text-decoration: underline; color: blue;"><strong>+2011-blogit</strong></span></p>
<div class="shcontent">
<a href="blogi/archive/2011/1/">tammikuu 2011 - (3)</a> <br />
<a href="blogi/archive/2010/2/">helmikuu 2011 - (3)</a> <br />
<a href="blogi/archive/2011/3/">maaliskuu 2011 - (4)</a> <br />
<a href="blogi/archive/2011/4/">huhtikuu 2011 - (1)</a> <br />
etc.


Page's meta data

<__script__ type="text/javascript" src="modules/jQuery/libraries/jquery-1.4.2/jquery.js"></__script>
{literal}
<__script__ type="text/javascript">
jQuery(document).ready(function() {
jQuery(".shcontent").hide();
jQuery(".shtitle").click(function()
{
jQuery(this).next(".shcontent").slideToggle(500);
});
});
</__script>
{/literal}


Page's CSS

.shtitle {
cursor: pointer;
}

.shcontent {
}


Blog archive code

{* archive template *}
{assign var=arcyear value="2012"}
{if isset($archivelist)}
<ul>
{foreach from=$archivelist item=one}
{if $one.datestamp|date_format:"%Y" == $arcyear}
<li><a href="{$one.summary_url}">{$one.datestamp|date_format:"%B"} {$one.datestamp|date_format:"%Y"} - ({$one.count})</a></li>
{/if}
{/foreach}
</ul>
{/if}
Post Reply

Return to “Modules/Add-Ons”