The basis is to keep the numbering of news articles equal to cgblog articles. This because it helps you to 'link' comments being made to the blog article.
0. Create a backup of the database and store it in a safe place!!!!
1. Install CGBlog
2. Install CGFeedback
3. Insert News-items into CGBlog. Replace 'Your Name' with the writer of the article. In this case all articles are written by me. If you have more writers, you have to add these names manually.
Code: Select all
insert into cms_module_cgblog
(`cgblog_id`, `cgblog_title`, `cgblog_data`, `cgblog_date`, `summary`, `start_time`, `end_time`, `status`, `create_date`, `modified_date`, `author`, `cgblog_extra`, `url`)
select
`news_id`, `news_title`, `news_data`, `news_date`, `summary`, `start_time`, `end_time`, `status`, `create_date`, `modified_date`, “Your Name”, `news_extra`, NULL
from cms_module_news
5. Insert the news categories into the cgblog categories:
Code: Select all
insert into cms_module_cgblog_categories
(`id`, `name`, `sort_order`)
select
`news_category_id`, `news_category_name`, `hierarchy`
from cms_module_news_categories
7. Insert the relation between the blog categories and the news categories:
Code: Select all
insert into cms_module_cgblog_blog_categories
(`blog_id`, `category_id`)
select
`news_id`, `news_category_id`
from cms_module_news
Code: Select all
insert into cms_module_cgblog_fielddefs
(`id`, `name`, `type`, `max_length`, `create_date`, `modified_date`, `item_order`)
select
`id`, `name`, `type`, `max_length`, `create_date`, `modified_date`, `item_order`
from cms_module_news_fielddefs
Code: Select all
insert into cms_module_cgblog_fieldvals
(`cgblog_id`, `fielddef_id`, `value`, `create_date`, `modified_date`)
select
`news_id`, `fielddef_id`, `value`, `create_date`, `modified_date`
from cms_module_news_fieldvals
Code: Select all
insert into cms_module_cgblog_seq
(`id`)
select
`id`
from cms_module_news_seq
If News articles have related comments, one can re-use these by replacing the word 'news' in the comments-table by the word 'CGBlog'. Because we keep the numbering the same, the comments will show up with the according blog article. This was a manual action. If you use CGFeedback, you can follow the same steps.
To 'connect' twitter to CGBlog, create a new UDT 'blog_twitter_update_status' containing the following code:
Code: Select all
/*********************************************************************************
* about
*********************************************************************************/
/*
This UDT can be used to automatically post a Twitter message when a CGBlog article is added.
The functionality is based on the Twitter and CGBlog module.
- First you need to install and setup the CGBlog and Twitter module.
- After you need to create a UDT with this code, for example you can call it: 'blog_twitter_update_status'
- At last you need to connect this UDT to the 'CGBlogArticleAdded' event.
This can be done via Extensions -> Event Manager.
! Currently this UDT only works when pretty urls are enabled.
It seems that the bit.ly url shortner ($twitter->shortenUrls($link)) has some problems with unfriendly urls.
Querystring parameters &var=1 are converted to &=1 which will break the link.
*/
/*********************************************************************************
* globals / objects
*********************************************************************************/
global $gCms;
$twitter = $gCms->modules['Twitter']['object'];
$cgblog = $gCms->modules['CGBlog']['object'];
$root_url = $gCms->config['root_url'];
$debug = '0';
/*********************************************************************************
* variables
*********************************************************************************/
/* custom (string) */
$detailpage = '15';
/* blog article related (string) */
$cgblog_id = $params['cgblog_id'];
$title = $params['title'];
/* added to link (array) */
$link['articleid'] = $params['cgblog_id'];
/*********************************************************************************
* program
*********************************************************************************/
$aliased_title = munge_string_to_url($title);
$prettyurl = 'logboek/' . $cgblog_id.'/'.$detailpage."/$aliased_title";
$prettyfullurl = $root_url . '/'. $prettyurl;
/* shorten URL does not work that well when pretty links are not enabled */
if ($debug) {
$link = $cgblog->CreateLink($news_id, 'detail', $detailpage, '', $link,'', true, false, '', true, $prettyurl);
$shortlink = $twitter->shortenUrls($link);
//$message = $title.' '. $shortlink;
print "<pre>link: $link / shortlink: $shortlink \n</pre>";
}
$message = $title. ' '. $prettyfullurl;
if ($debug) {
print "<pre>twitter: $message status: $params[status] \n</pre>";
} else {
if ($params[status] == 'published') {
$twitter->updateStatus($message, false);
}
}

Gregor