De afgelopen week heb ik met sql statements de combinatie News + Comments omgezet naar CGBlog. Ik zal een opsomming geven met bijbehorende statements (sorry, afwisselend NL en Eng.).
Het uitgangspunt is, de nummering van de blog artikelen gelijk te houden aan de news artikelen. Dit helpt met het overzetten van comments of feedback.
0. Maak een backup van je database!!!!
1. Installeer CGBlog
2. Installeer CGFeedback
3. Insert de News-items into CGBlog. Vervang 'Your Name' door je eigen naam. Als er meerdere schrijvers zijn, dan zal je per artikel de juiste naam moeten aanpassen, eventueel na de insert.
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
4. First delete all rows from the cgblog_category table, so you have an empty table
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
6. Make sure that the sort_order column from the 'Category' table has unique values (has to do with sub categories from News, those with a ‘|’ symbol). Manual correction.
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
8. If you have made any field definitions in News, insert these into field defs. from the cgblog module:
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
9. Insert the field values, if any:
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
10. Make sure you add the correct sequent number:
Code: Select all
insert into cms_module_cgblog_seq
(`id`)
select
`id`
from cms_module_news_seq
De volgende stap is het controleren van je templates. Ik heb de News templates in de CGBlog templates gekopieerd en de variabele aangepast. Gelukkig worden gelijke benamingen gebruikt en hoefde ik maar nauwelijks aanpassingen te doen.
Als er comments zijn gemaakt bij een News article, dan kan je die 'meenemen' door in de tabel Comments het overeenkomstige comment aan te passen door 'News' te vervangen door 'CGBlog'. Doe dit handmatig. Controleer en pas zonodig ook CGFeedback aan.
Om twitter ook weer te laten aansluiten op CGBlog heb ik een nieuwe UDT gemaakt 'blog_twitter_update_status' met de volgende 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);
}
}
Het was even puzzelen, maar het werkt wel
Gregor