Page 2 of 2
Re: CGBlog - A several of things
Posted: Mon Sep 27, 2010 10:04 am
by hoodedman
Peciura wrote:
3. It can be done with a single UDT
4. I have done somewat similar pagination for Products and "ugly url" You can easily adopt it to any module
http://forum.cmsmadesimple.org/index.ph ... #msg223502
If you need more help post summary template and link to your page.
Thanx for help.
3. About calendar.... can you point me to something helpful on that matter???
4. Will try to adopt it to the blog, thanx.
Re: CGBlog - A several of things
Posted: Mon Sep 27, 2010 2:22 pm
by Peciura
3. write UDT that takes date and returns an array of article ids. Having that you can create link for each article created on the same date as calendar cell.
Re: CGBlog - A several of things
Posted: Wed Sep 29, 2010 8:56 pm
by Peciura
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}
...
Re: CGBlog - A several of things. AGAIN!
Posted: Wed Jul 20, 2011 3:28 pm
by ncp911
hoodedman wrote: 1. How can I maintain pagenation per category when I browse them??? Is that possible, because
it is not working, only on the main page of blog entries.
(
SOLVED: just added pagelimit to browsecat mode)

This didn't work for me. I have the latest Version of ALL of the modules and CMSMS what the heck am i doing wrong. my code looks like this
Code: Select all
{CGBlog action='browsecat' pagelimit="10"}
Is there somthing I am missing?