Re: News Archives by Year/Month
Posted: Thu Jul 24, 2008 11:46 am
blast, are you God?
Content management as it is meant to be
https://forum.cmsmadesimple.org/
sam_butler wrote: blast, are you God?
Code: Select all
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);
Code: Select all
{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"}
Code: Select all
{if isset($detail_title)}
<title>{$detail_title} - {sitename}</title>
{else}
<title>{title} - {sitename}</title>
{/if}
Code: Select all
<a title="News Archive 2008" href="{cms_selflink href='news-archive'}?year=2008">2008</a>
Yeah, I did that just now... UDT called 'news_archive_sidebar' with comments: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').
Code: Select all
//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>";
Sorry Mark, I didn't get you there - change what?mark wrote: Why don't change it and say for previous users bla bla bla ...?
1. Has the patch been integrated with latest version (1.4.1 now)?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.