Page 1 of 1

[SOLVED] CGBlog display by month and year

Posted: Mon Jul 27, 2009 5:10 am
by Simon66
I'm trying to get the CGBlog to only display the current months blogs in a summary list. If I can get the year working first, I will add months later.

I've assigned a variable in smarty:
{assign var=thisyear value='$smarty.now|date_format:"%Y"'}
Then called it in the CGBlog smarty:
{CGBlog detailpage='Blog' year='$thisyear'}

This just makes the summary list disappear. I've tried every combination of single and double quotes but I get nothing or a smarty error.

Even if I put the year in literally it just ignores it and displays all years e.g {CGBlog detailpage='Blog' year='2009'}

Musings, ponderings and brainwaves gratefully accepted
Simon66

P.S. Anybody know how to do a nested bullet point nav by year and month (see below, with totals but without the dropdown titles)
Image

Re: CGBlog display by month and year

Posted: Tue Jul 28, 2009 7:28 am
by Simon66
Thanks Ajprog for helping me out with this one.

The fix:
{assign var=thisyear value=$smarty.now|date_format:"%Y"}
{CGBlog detailpage='Blog' year=$thisyear}

Re: [SOLVED] CGBlog display by month and year

Posted: Fri Jul 31, 2009 8:16 pm
by Duketown
Simon66,

I'm able to generate hyperlinks for a number of months to the blog items (doesn't work 100%).
I've prepared the following code (which I put in a global content block to easily remove it from a page):

Code: Select all

{assign var=thisyear value=$smarty.now|date_format:"%Y"}

{assign var=thismonth value=$smarty.now|date_format:"%m"}

{assign var=oneyear value=1}

{CGBlog action=browsecat year=$thisyear month=$thismonth}

{section name=years loop=$thisyear+$oneyear max=2 step=-1}

  {assign var=year value=$smarty.section.years.index}

  {section name=bar loop=13 max=12 step=-1}
    {assign var=month value=$smarty.section.bar.index}{if $smarty.section.bar.index == 1}{assign var=monthletters value="Jan"}{/if}{if $smarty.section.bar.index == 2}{assign var=monthletters value="Feb"}{/if}{if $smarty.section.bar.index == 3}{assign var=monthletters value="Mar"}{/if}{if $smarty.section.bar.index == 4}{assign var=monthletters value="Apr"}{/if}{if $smarty.section.bar.index == 5}{assign var=monthletters value="May"}{/if}{if $smarty.section.bar.index == 6}{assign var=monthletters value="Jun"}{/if}{if $smarty.section.bar.index == 7}{assign var=monthletters value="Jul"}{/if}{if $smarty.section.bar.index == 8}{assign var=monthletters value="Aug"}{/if}{if $smarty.section.bar.index == 9}{assign var=monthletters value="Sep"}{/if}{if $smarty.section.bar.index == 10}{assign var=monthletters value="Oct"}{/if}{if $smarty.section.bar.index == 11}{assign var=monthletters value="Nov"}{/if}{if $smarty.section.bar.index == 12}{assign var=monthletters value="Dec"}{/if}{$monthletters} {$year}
  {/section}

{/section}
Ok, ok, I know it is not the pretiest coding but it shows the correct month name (which I wanted).
Currently the hyperlinks are not opening the correct detail page.
I don't like the fact that future months are included and that the month/year is shown even if there is no blog for that specific month.

Hope this helps you and maybe you (or other readers of this thread) can help me out in return.

Duketown

Re: [SOLVED] CGBlog display by month and year

Posted: Sun Aug 02, 2009 4:50 am
by Jeff
CGBlog does have an archive feature that does work. The problem is that CGBlog has multiple date fields and if you have posts that were imported in incorrectly then they may not show up as expected.