• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: News Archives by Year/Month
PostPosted: Thu Jul 24, 2008 11:46 am 
Offline
Forum Members
Forum Members

Joined: Sun Jul 20, 2008 3:36 pm
Posts: 24
blast, are you God?


Top
 Profile  
 
 Post subject: Re: News Archives by Year/Month
PostPosted: Thu Jul 24, 2008 12:04 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Aug 01, 2007 5:36 pm
Posts: 485
sam_butler wrote:
blast, are you God?


???

what do you mean?


Last edited by blast2007 on Thu Jul 24, 2008 12:08 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: News Archives by Year/Month
PostPosted: Thu Jul 24, 2008 1:44 pm 
Offline
Forum Members
Forum Members

Joined: Sun Jul 20, 2008 3:36 pm
Posts: 24
Sorry, haha, I just meant your solution was excellent. I guess British jokes don't work with Italians  :-\

Will install the diff soon and let you know how it goes. Thanks again.


Top
 Profile  
 
 Post subject: Re: News Archives by Year/Month
PostPosted: Wed Jul 30, 2008 2:08 pm 
Offline
Forum Members
Forum Members

Joined: Sun Jul 20, 2008 3:36 pm
Posts: 24
Wow, I've been busy. Okay, here's what I did:
1) Installed the patch from the diff (see above) so I can set start/end dates for a news summary;

2) Created a new page with the alias 'news-archive' as a child of 'news';

3) Thought a little bit, then realised the best way to do it without creating a new page for each year would be to pass a variable in the query string...

4) Wrote a UDT called 'news_archive_setup':
Code:
global $gCms;
global $smarty;

if (!isset($_GET['year']) || $_GET['year'] == "") {
 $archiveyear=date('Y');
}
else {
 $archiveyear=$_GET['year'];
}
 $startperiod="{$archiveyear}/01/01";
 $endperiod="{$archiveyear}/12/31";
 $title="News Archive ".$archiveyear;
 
 $smarty->assign('archiveyear', $archiveyear);
 $smarty->assign('startperiod', $startperiod);
 $smarty->assign('endperiod', $endperiod);
 $smarty->assign('detail_title', $title);

5) Didn't quite get it right, had to learn the hard way that you can't concatenate strings in smarty (at least not easily), learned how to assign variables to smarty, and finally came up with the simple code above (I could add some regex to check that what was entered was an integer of four digits, but it's not needed right now);

6) Put the following in the content of my archives page:
Code:
{news_archive_setup}
<h3 class="center">{title} – {$archiveyear}</h3>
<p style="text-align: center;">{anchor anchor="archives" title="News Archives" text="Choose another year"}</p>
{news summarytemplate="archive" detailpage="view-news" startperiod=$startperiod endperiod=$endperiod sortasc="true"}


7) I did this before, but if someone else wants to use the variable 'detail_title' as assigned in the UDT, here's what I have in the of my template:
Code:
{if isset($detail_title)}
  <title>{$detail_title} - {sitename}</title>
{else}
  <title>{title} - {sitename}</title>
{/if}


8 ) Created a sidebar with links to each of the years of the archive (I was going to write something to make this dynamic based on what years there are news items for, but I ran out of time) like this:
Code:
<a title="News Archive 2008" href="{cms_selflink href='news-archive'}?year=2008">2008</a>

The heading of this sidebar appears down the page, so it's anchored as 'archives', which is linked to with the smarty {anchor} in the content above. Also there's an {if} statement in my template to display the news archive sidebar in place of the last three articles if you're on the news summary page or an archive page. (Oh, and I thought after that the easiest way to make the list of links, since I'm doing it with yearly archives, would be to have a UDT to loop through from an arbitrary starting year, in my case 2003, until it reaches date('Y').)

9) Rejoiced and moved on to satisfy the next of my client's desires.

Thanks to all who helped, and I'll accept any suggestions for improving the efficiency of the solution I came up with based on the contribs here. Main thing is it works FINALLY! ::)


Top
 Profile  
 
 Post subject: Re: News Archives by Year/Month
PostPosted: Wed Jul 30, 2008 2:51 pm 
Offline
Forum Members
Forum Members

Joined: Sun Jul 20, 2008 3:36 pm
Posts: 24
sam_butler wrote:
Oh, and I thought after that the easiest way to make the list of links, since I'm doing it with yearly archives, would be to have a UDT to loop through from an arbitrary starting year, in my case 2003, until it reaches date('Y').


Yeah, I did that just now... UDT called 'news_archive_sidebar' with comments:

Code:
//Execute some smarty code to make the archive link
global $gCms;
$smarty = &$gCms->GetSmarty();
$smarty_data = "{cms_selflink href='news-archive'}"; //this is the archive link
$smarty->_compile_source('temporary template', $smarty_data, $_compiled );
@ob_start();
$smarty->_eval('?>' . $_compiled);
$_contents = @ob_get_contents();
@ob_end_clean();
$archivelink = $_contents;

//Set the first year of archives:
$firstyear=2003;

//Set some variables
$thisyear=date('Y');
$i=$firstyear;

//HTML before the loop
echo "<ul>";

//Loop through the years to this year
while ($i <= $thisyear) {
 echo "<li>"; //HTML at beginning of iteration
 echo "<a title="News Archive {$i}" href="{$archivelink}?year={$i}">{$i}</a>";
 echo "</li>"; //HTML at end of iteration
 ++$i;
}

//HTML after the loop
echo "</ul>";


Might be useful to someone...


Last edited by sam_butler on Thu Jul 31, 2008 4:47 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Wed Jul 30, 2008 10:03 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 11822
Location: Arizona
Why don't change it and say for previous users bla bla bla ...?

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Thu Jul 31, 2008 3:44 pm 
Offline
Forum Members
Forum Members

Joined: Sun Jul 20, 2008 3:36 pm
Posts: 24
mark wrote:
Why don't change it and say for previous users bla bla bla ...?


Sorry Mark, I didn't get you there - change what?


Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Thu Jul 31, 2008 4:31 pm 
Offline
Power Poster
Power Poster

Joined: Sat Feb 04, 2006 1:24 am
Posts: 322
Location: London, England
I think he means modify the code example so that people don't copy and paste it before reading your correction.


Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Thu Jul 31, 2008 4:48 pm 
Offline
Forum Members
Forum Members

Joined: Sun Jul 20, 2008 3:36 pm
Posts: 24
Done.


Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Mon Oct 27, 2008 11:33 am 
Offline
New Member

Joined: Thu Sep 25, 2008 3:34 pm
Posts: 5
Interesting post, as this Word Press-type archive is exactly what we're after with bringing locustvalleyfd.com over to CMSms. Before digging into this too much, I was wondering if...


blast2007 wrote:
Calguy told me that we have to wait until 1.4 is out before these kind of patches will be integrated in the official module. We hope.


1. Has the patch been integrated with latest version (1.4.1 now)?

2. Has there been any update to the News Menu mod that NaN posted above?

Thanks!


Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Mon Oct 27, 2008 1:18 pm 
Since there was no response if it works or not I did no updates yet.
I'm just using this in one single page and there it works like it should.
I'm not going to publish it into the forge since I've read that there will be a solution in the new CMS version.


Top
  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Mon Oct 27, 2008 3:02 pm 
Offline
New Member

Joined: Thu Sep 25, 2008 3:34 pm
Posts: 5
Hi NaN,

Thanks for the reply. Could you post the link to what you've read regarding a solution in next CMS version?

Thank you!


Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Mon Oct 27, 2008 3:14 pm 
It was mentioned in the current topic by blast2007 ;)

http://forum.cmsmadesimple.org/index.ph ... #msg116827


Last edited by NaN on Mon Oct 27, 2008 3:21 pm, edited 1 time in total.

Top
  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Wed Dec 03, 2008 11:09 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Aug 01, 2007 5:36 pm
Posts: 485
mmm....

News module 2.9 (CMSMS 1.5) still misses this most-wanted ready-to-apply patch

...anyone can tell us why?

Regards
blast


Top
 Profile  
 
 Post subject: Re: [SOLVED] News Archives by Year/Month
PostPosted: Fri Dec 05, 2008 1:31 pm 
Offline
Forum Members
Forum Members

Joined: Thu Aug 21, 2008 11:47 am
Posts: 70
Blast,

Any chance of you re-posting the link to the patch? It seems to be a dead link now and I could really do with having this functionality.



Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner