Page 1 of 1
Smarty New Template Help
Posted: Tue Oct 31, 2006 5:13 am
by Kavrick
Hi - Just wondering if anyone can help me with a news template? I need to be able to group news by month (just like this
http://www.dundeereit.com/NewsEvents-PressRel2006.html) and am not sure where to start.
Code samples or links would be greatly appreciated.
Cheers,
David
Re: Smarty New Template Help
Posted: Tue Oct 31, 2006 6:44 am
by Dr.CSS
You could put them in monthly categories and call the categories in each div...
Re: Smarty New Template Help
Posted: Tue Oct 31, 2006 10:57 pm
by Kavrick
Wow - I wrote that late last night and wasn't nearly specific enough... Sorry about that Mark.
I've actually already got my news posts in categories by month... What I was hoping for was a way for the press release page to recognise the current month and start displaying the previous month's entries by working backwards from the current month.
I'm really just looking to simplify the admin of this page.
Is there a way for Smarty to grab the current month (based on server values) and then just display backwards from there?
Let me know if I'm not making any sense!
David
Re: Smarty New Template Help
Posted: Wed Nov 01, 2006 12:24 pm
by tsw
iirc $smarty.now has current datetime and you can of course specify only moth with something like $smarty.now|date_format %m, but check the right syntax from smarty manual
Re: Smarty New Template Help
Posted: Wed Nov 01, 2006 7:47 pm
by Kavrick
Thanks for the suggestions... Any good links to Smarty Tutorials?
David
Re: Smarty New Template Help
Posted: Thu Nov 02, 2006 6:29 am
by cyberman
Re: Smarty New Template Help
Posted: Fri Nov 03, 2006 7:10 am
by Kavrick
Thanks for everyone's suggestions. I got it figured out and thought I'd share. Before anyone rips into me about using tables... I know. This was a time sensitive thing and I had to blast it up quick. I'll convert it to CSS later... I swear!
Since I have each press release categorized by Year, Month I created this little template and essentially made 12 calls to each individual monthly category.
The Template looks like this...
{foreach name="dategroup" from=$items item=entry}
{if $smarty.foreach.dategroup.first}
{$entry->category}
{$entry->formatpostdate}
{$entry->titlelink} {$entry->morelink}
{else}
{$entry->formatpostdate}
{$entry->titlelink} {$entry->morelink}
{/if}
{if $smarty.foreach.dategroup.last}
{/if}
{/foreach}
You can actually see the result here...
http://www.instoragereit.ca/pressroom
As they add releases, they will show automagically based on the month! Yippeee
Anyway, not the cleanest solution but it works for now!
Re: Smarty New Template Help
Posted: Fri Nov 03, 2006 6:42 pm
by Dr.CSS
Came out real nice..... but...
The pressroom page has 131 errors not valid...
http://validator.w3.org/check?verbose=1 ... essroom%2F
and the article itself... 86...
http://validator.w3.org/check?verbose=1 ... F6%2F32%2F