Here is an example of an UDT
{get_cgblog_article_by_date}. It gets basic data of an CGBlog article for each day.
Code: Select all
//$params['assign'] Mandatory. Variable name to store result in.
//$params['time_stamp'] Mandatory. Unix time stamp of an articles to search.
//$params['criterion'] Mandatory. E.g. : 'cgblog_date', 'start_time', 'end_time', 'create_date', 'modified_date'
if (!empty($params['assign']) &&
!empty($params['time_stamp'])){
$gCms = cmsms(); //global $gCms;
$smarty = $gCms->GetSmarty();
$db = $gCms->GetDB();
$query = "SELECT * FROM `cms_module_cgblog` WHERE `%s` LIKE ? AND `status` = 'published'";
$criterion = (empty($params['criterion']))? '' : trim($params['criterion']);
$db_result = array();
$date_format = 'Y-m-d';
$date = date($date_format, trim($params['time_stamp']));
switch ($criterion){
case 'start_time':
case 'end_time':
case 'create_date':
case 'modified_date':
break;
default:
$criterion = 'cgblog_date';
break;
}
$query = sprintf($query, $criterion);
$db_result = $db->GetArray($query, array($date.' %'));
$smarty->assign($params['assign'], $db_result);
}
That is what it returns for each article
Code: Select all
array(12) {
["cgblog_id"]=>"1"
["cgblog_title"]=>"test"
["cgblog_data"]=>"test..."
["cgblog_date"]=>"2009-09-22 15:17:55"
["summary"]=>""
["start_time"]=>"2009-09-22 15:17:10"
["end_time"]=>"2010-03-21 15:17:10"
["status"]=>"published"
["create_date"]=>"2009-09-22 15:17:55"
["modified_date"]=>"2009-09-22 15:17:55"
["author"]=>"unknown"
["cgblog_extra"]=>""
}
If you want you can build simple summary for each article. If you want to use custom fields call CGBlog in detail mode with appropriate template.
Paste this bit of Smarty to CGCalendar template. It uses former UDT to get article ids and
CGSimpleSmarty to create link for each of them.
...
{get_cgblog_article_by_date assign='articles' time_stamp=$day.date}
{if !empty($articles)}
{foreach from=$articles item='article'}
{module_action_link module='CGBlog' action='detail' articleid=$article.cgblog_id text=$article.cgblog_title}
{/foreach}
{/if}
...