[SOLVED] CGBlog display by month and year

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

[SOLVED] CGBlog display by month and year

Post 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
Last edited by Simon66 on Tue Jul 28, 2009 7:30 am, edited 1 time in total.
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.

This must be Thursday. I never could get the hang of Thursdays.

Douglas Adams - The only sane person in the asylum.
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am
Location: Sydney Australia

Re: CGBlog display by month and year

Post 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}
Last edited by Simon66 on Tue Jul 28, 2009 7:30 am, edited 1 time in total.
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.

This must be Thursday. I never could get the hang of Thursdays.

Douglas Adams - The only sane person in the asylum.
Duketown

Re: [SOLVED] CGBlog display by month and year

Post 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
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: [SOLVED] CGBlog display by month and year

Post 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.
Post Reply

Return to “Modules/Add-Ons”