[SOLVED] News Archives by Year/Month

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: [SOLVED] News Archives by Year/Month

Post by blast2007 »

oliverseddon wrote: 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.
Hi oliverseddon,

after this great forge restying, it seems that all old posts (feature request and bug tracking) were deleted.

Anyway you can check this post.

regards
blast
oliverseddon
Forum Members
Forum Members
Posts: 89
Joined: Thu Aug 21, 2008 11:47 am

Re: [SOLVED] News Archives by Year/Month

Post by oliverseddon »

Thanks for the link, unfortunately I don't understand any of what is being said and can't fathom what I need to change to solve it. Any ideas?



Thanks
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: [SOLVED] News Archives by Year/Month

Post by blast2007 »

oliverseddon wrote: Thanks for the link, unfortunately I don't understand any of what is being said and can't fathom what I need to change to solve it. Any ideas?



Thanks
Sorry oliverseddon for that,

you have to download patch file (news.period.mpg), then rename to .zip and uncompress it.

After that you can apply patch to distribution files.

Hope this helps
regards
blast
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [SOLVED] News Archives by Year/Month

Post by calguy1000 »

Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: [SOLVED] News Archives by Year/Month

Post by blast2007 »

calguy1000 wrote: Please remember this post:
http://forum.cmsmadesimple.org/index.php/topic,28132.0.html
I've read that post, ...but it seems that you simply ignore previous messages.

I can't still understand why this patch can't be merged in the official module.

The patch is ready from feb 2008. There are less than 10 lines of code, so it's not so difficult to check them and to merge in SVN.

I hope a "sponsor" will need this feature because in that case it will be ready very soon.
oliverseddon
Forum Members
Forum Members
Posts: 89
Joined: Thu Aug 21, 2008 11:47 am

Re: [SOLVED] News Archives by Year/Month

Post by oliverseddon »

Thanks. I've now got the news.period.diff file. How do I run the update? I can't seem to find any details on the process anywhere.



Thanks
Oliver
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: [SOLVED] News Archives by Year/Month

Post by blast2007 »

oliverseddon wrote: Thanks. I've now got the news.period.diff file. How do I run the update? I can't seem to find any details on the process anywhere.
You can proceed in three ways:

- by hand (editing each file listed. A "+" in patch file stands for "add this line", a "-" for delete this line)
- using win program like tortoiseSVN
- using linux "patch" command

regards
blast
oliverseddon
Forum Members
Forum Members
Posts: 89
Joined: Thu Aug 21, 2008 11:47 am

Re: [SOLVED] News Archives by Year/Month

Post by oliverseddon »

Thanks for all your help. I have finally managed to get it up and running, I'm on a Mac so tried the patch command in Terminal but it kept giving me errors so I just ended up manually altering the files. I'm running CMS 1.4.1 on the particular site I've been working on and noticed that some of the line numbers that needed altering were slightly different, so I don't know if that was causing the conflict when I was trying to run the Patch command.

Take a look at the result if your interested:

http://www.addmaster.co.uk


Thanks again.

P.S
This is a really beneficial feature, why hasn't it been added to the News module as standard yet?  ???
Ziggywigged
Power Poster
Power Poster
Posts: 424
Joined: Sat Feb 02, 2008 12:42 am
Location: USA

Re: [SOLVED] News Archives by Year/Month

Post by Ziggywigged »

oliverseddon wrote: This is a really beneficial feature, why hasn't it been added to the News module as standard yet?  ???
Just want to add my request to have this feature added to the news module.
Take a penny, leave a penny.
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: [SOLVED] News Archives by Year/Month

Post by blast2007 »

Said that I won't start flame...

...I think you should give it up.

Read this signature from our "CMS GURU - 2nd Tier Support" and you can understand why it's impossible to add this feature:
...
"I don't ignore everybody.... Just the ones I chose to.
and.. I accept it: I DO have an attitude problem."
Ziggywigged
Power Poster
Power Poster
Posts: 424
Joined: Sat Feb 02, 2008 12:42 am
Location: USA

Re: [SOLVED] News Archives by Year/Month

Post by Ziggywigged »

Any CMSMS devs out there want to give an estimate of what it would cost to implement this feature as part of the core news module? Maybe I can get a client to sponsor the change.
Last edited by Anonymous on Wed Jan 28, 2009 2:10 pm, edited 1 time in total.
Take a penny, leave a penny.
benchfrooser
Forum Members
Forum Members
Posts: 28
Joined: Thu Jan 08, 2009 1:28 pm

Re: [SOLVED] News Archives by Year/Month

Post by benchfrooser »

calguy1000 wrote: Please remember this post:
http://forum.cmsmadesimple.org/index.php/topic,28132.0.html
Your link doesn´t answer why not implement this new function.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: [SOLVED] News Archives by Year/Month

Post by Dr.CSS »

If you would like to sponsor(pay for) this addition to the news module I'm sure a quick email or request in the modules forge page could make it happen, if you wonder why calguy hasn't added it yet it may be because atm he is working on paying projects...
tamsrud
Forum Members
Forum Members
Posts: 37
Joined: Mon Jun 06, 2011 6:25 am

Re: [SOLVED] News Archives by Year/Month

Post by tamsrud »

I was in the need for a archive function as described in this post. With a different approch i got it working without any modifications of the news module.

Insted I use the fact that you can filter what news that are displayed based on post id.

I used the default news summary function to provide the month/year list like this:
2010
• November (9)
• December (16)
2011
• January (2)
It is created with the following news summary template:

Code: Select all

<!-- Start Categorylist -->
{foreach from=$cats item=node}
{if $node.count > 0}<a href="/news-archive/?category={$node.news_category_name}">{$node.news_category_name}</a>
{else}<span>{$node.news_category_name}</span>{/if}&nbsp;
{/foreach}
<hr/>
<!-- Start News Archive -->
<ul class="list2">
{assign var="month_count" value=0}
{assign var="post_count" value=0}
{assign var="startpost" value=0}
{foreach from=$items item=entry}
{if $entry->postdate}
  {assign var="post_year" value=$entry->postdate|date_format:"%Y"}
  {assign var="post_month" value=$entry->postdate|date_format:"%m"}
  {if $post_month != $lastpost_month && $lastpost_month}
<li>
<a href="{cms_selflink href='news-archive'}?startpost={$startpost}&numposts={$month_count}&pagetitle={$lastpost_monthname}-{$lastpost_year}">
{$lastpost_monthname}</a> ({$month_count})</li>
    {assign var="month_count" value=1}
    {assign var="startpost" value=$post_count}
  {else}
    {math equation="x + 1" x=$month_count assign="month_count"}  
  {/if}
  {if $post_year != $lastpost_year && $lastpost_year}</ul></li>{/if}
  {if $post_year != $lastpost_year}
    <li>{$post_year}<ul>
  {/if}
  {assign var="lastpost_year" value=$post_year}
  {assign var="lastpost_month" value=$post_month}
  {assign var="lastpost_monthname" value=$entry->postdate|date_format:"%B"}
  {math equation="x + 1" x=$post_count assign="post_count"}
{/if}
{/foreach}
<li>
<a href="{cms_selflink href='news-archive'}?startpost={$startpost}&numposts={$month_count}&pagetitle={$lastpost_monthname}-{$lastpost_year}">
{$lastpost_monthname}</a> ({$month_count})</li>
</ul></li></ul>
<!-- End News Archive -->
To display the correct news it is requred to have a page with alias news-archive . In this page, disable WYSIWYG and paste the folowing code:

Code: Select all

{news_archive_setup}
<h1>{$pagetitle}</h1>
{if $category}{news category=$category}
{else}{news start=$startpost pagelimit=$numposts}
{/if}
And finaly add a UDT called news_archive_setup:

Code: Select all

global $gCms;
global $smarty;

if (isset($_GET['category']) || $_GET['category'] != "") {
$category=$_GET['category'];
$smarty->assign('category', $category);
}
if (!isset($_GET['startpost']) || $_GET['startpost'] == "") {
$startpost=0;
} else {
$startpost=$_GET['startpost'];
}
if (!isset($_GET['numposts']) || $_GET['numposts'] == "") {
$numposts=20;
} else {
$numposts=$_GET['numposts'];
}
if (isset($_GET['pagetitle']) || $_GET['pagetitle'] != "") {
$pagetitle= htmlentities("Newsarchive - ".$_GET['pagetitle']);
} elseif (isset($_GET['category']) || $_GET['category'] != "") {
$pagetitle= htmlentities("Newsarchive - ".$_GET['category']);
} else {
$pagetitle="Newsarchive";
}

$smarty->assign('startpost', $startpost);
$smarty->assign('numposts', $numposts);
$smarty->assign('pagetitle', $pagetitle);
jlmcm
New Member
New Member
Posts: 8
Joined: Tue Jun 21, 2011 8:51 pm

Re: [SOLVED] News Archives by Year/Month

Post by jlmcm »

I was in the need for a archive function as described in this post. With a different approch i got it working without any modifications of the news module.
I just tried this, and it doesn't work (for me at least). It produces a nice, populated list of links, but they don't point to the stories. They point to new pages with more lists on them, and the links in those lists don't point anywhere.
Post Reply

Return to “Developers Discussion”