sorry peciura!
But i have one problem left.
the archive isnt ordered by date! i dont know why!
you see it here:
http://www.smomkenya.org/news-archive
i tried to find the problem in UDT "news_date":
Code: Select all
/*$params['assign']*//*mandatory*/
/*$params['date']*//*mandatory*//*9999-12-32 23:59:59*/
/* $params['sort_by']*//* create_date, modified_date, start_time, end_time, news_extra, news_id, news_title, news_date */
/* $params['sort_order'] */ /* ASC, DESC */
if (!empty($params['assign']) && !empty($params['date'])){
$params['sort_by'] = trim(strtolower($params['sort_by']));
switch ($params['sort_by']){
case 'modified_date':
case 'news_id':
case 'news_title':
case 'news_date':
case 'start_time':
case 'end_time':
case 'news_extra':
$sort_by = $params['sort_by'];
break;
default:
$sort_by = 'create_date';
break;
}
$params['sort_order'] = trim(strtoupper($params['sort_order']));
switch ($params['sort_order']){
case 'ASC' :
$sort_order = $params['sort_order'];
break;
default:
$sort_order = 'DESC';
break;
}
$params['date'] = substr(trim($params['date']), 0, 19);
$start_date = substr_replace('0000-00-00 00:00:00', $params['date'], 0, strlen($params['date']));
$end_date = substr_replace('9999-12-31 23:59:59', $params['date'], 0, strlen($params['date']));
$assign = '';
global $gCms;
$db =& $gCms->GetDB();
$query = 'SELECT news_id FROM '.cms_db_prefix()."module_news WHERE news_date >= ? AND news_date <= ? AND status = ? ORDER BY $sort_by $sort_order";
$array = $db->GetArray($query,array($start_date, $end_date, 'published'));
foreach($array as $row){
$assign .= $row['news_id'].',';
}
$assign = rtrim($assign, ' ,');
$smarty = $gCms->GetSmarty();
$smarty->assign($params['assign'], $assign);
}
but i found nothing. whats wrong?
this is the GCB:
Code: Select all
{news_extreme_date assign=news_start_date extreme='min'}
{news_extreme_date assign=news_end_date extreme='max'}
{assign var='current_time' value='Y-m-d H:i:s'|date}
{assign var='active_year' value=$smarty.get.news_date|substr:0:4}
{assign var='start_year_list' value=$news_start_date|substr:0:4}
{assign var='loop_year_list' value=$news_end_date|substr:0:4}
<div class="newsarchivenavi">
{********** years ************}
<div class="newsarchivetitle">News in year:</div>
<ul class="newsbyyear">
{section name=year_list start=$start_year_list loop="`$loop_year_list+1`"}
<li>
{news_date assign='news_ids' date=`$smarty.section.year_list.index`} {*coment if you want to see links to periods without articles*}
{if !empty($news_ids)} {*coment if you want to see links to periods without articles*}
{capture assign=temp}?news_date={$smarty.section.year_list.index}{/capture}
{if $smarty.section.year_list.index == $active_year}
{$smarty.section.year_list.index}
{else}
{cms_selflink page=$page_alias urlparam=$temp text=$smarty.section.year_list.index}
{/if}
{/if} {*coment if you want to see links to periods without articles*}
</li>
{/section}
</ul>
{********** years end*********}
{********** months and news *******************}
{assign var=mod value=$gCms->modules.FormBuilder.object}
{assign var='temp' value='date_january,date_february,date_march,date_april,date_may,date_june,date_july,date_august,date_september,date_october,date_november,date_december'}
{assign var='months' value=','|explode:$temp}
{if !empty($smarty.get.news_date)}
<ul class="newsbymonth clear">
{********** months *************}
{foreach from=$months name='months' item=month}
{capture assign='news_date'}{$active_year}-{$smarty.foreach.months.iteration|string_format:"%'02u"}{/capture}
{if ($news_date >= $news_start_date && $news_date <= $news_end_date) || (strpos($news_start_date, $news_date) !== FALSE) || (strpos($news_end_date, $news_date) !== FALSE)}
{news_date assign='news_ids' date="`$news_date`"} {*coment if you want to see links to periods without articles*}
{if !empty($news_ids)} {*coment if you want to see links to periods without articles*}
<li>
{capture assign='text'}{$mod->Lang($months[$smarty.foreach.months.index])}{/capture}
{if $smarty.get.news_date!=$news_date}
{cms_selflink page=$page_alias text=$text urlparam="?news_date=$news_date"}
{else}
{$text}
{/if}
</li>
{/if} {*coment if you want to see links to periods without articles*}
{/if}
{/foreach}
</ul>
{/if}
<div class="clear"></div>
</div>
<div class="newsarchive">
{********** months end *********}
{********** news ***************}
{news_date assign='news_ids' date="`$smarty.get.news_date`" sort_by='create_date' sort_order='asc'}
{if !empty($news_ids)}
{*might be better option if you need all fields in articles *}
{assign var='news_ids' value=','|explode:$news_ids}
<div class="newssummary">
{foreach from=$news_ids item='articleid'}
<div class="newsitem clear{cycle values=' odd, even'}">
{news action='detail' detailtemplate='summary' articleid=$articleid}
</div>
{/foreach}
</div>
{*news_ids ids=$news_ids*}
{else}
{assign var=mod value=$gCms->modules.News.object}
{$mod->Lang('none')} {*Visitor will this message if there is no articles for this period*}
{/if}
{********** news end ***********}
</div>