Hi,
I think the main reason for BBCode is to add/edit blog articles on the published site using the Blog Management Widget. I did not want to do without the comfort of the TinyMCE editor either; I found it quite straightforward to modify the blog module. You probably found out how to change the Textarea field in the CMS to a HTMLEditorField through getCMSFields() in BlogEntry.php:
$fields->addFieldToTab("Root.Content.Main", new HtmlEditorField("Content", "Content", 20));
The paragraph summary that displays a short summary of blog articles in the Blog Holder, however, simply cuts off the text of blog modules. This is OK with BBCode, but with html code it may break the layout of blog posts on a Blog Holder page. So the next thing I modified was to replace the ParagraphSummary() and ParsedContent() methods in BlogEntry.php with:
function ParagraphSummary(){
return $this->Content;
}
function ParsedContent() {
return $this->Content;
}
There may be a more efficient way, but I wanted to make as little changes to the original code as possible so a future update of the blog module would be less painful.
Optional:
- - - - - - - - - - - - - - - - - - - - - - - -
To get the possibility to add a "read more/read the full post" link to the blog summary the easiest way I find is to add another field to the CMS, again in getCMSFields() in BlogEntry.php add this line below all other field definitions:
$fields->addFieldToTab("Root.Content.Main", new HtmlEditorField("ContentMore", "More", 10));
To add the field to the database add "ContentMore" => "Text" to the $db array in BlogEntry.php:
static $db = array(
"Date" => "Datetime",
"Author" => "Text",
"Tags" => "Text",
"ContentMore" => "Text",
);
I also added a new function that is useful for the template to the BlogEntry class:
function hasReadMore() {
if ($this->ContentMore == '' || $this->ContentMore == '<p></p>') {
return false;
}
return true;
}
You can then use this function in the BlogSummary.ss template, e.g.:
<% if hasReadMore %>
<a href="$Link" title="Read Full Post">Read the full post</a>
<% end_if %>
To display the additional content add the $ContentMore variable to the BlogEntry.ss template, e.g.:
<h3>$MenuTitle</h3>
$Content
$ContentMore
- - - - - - - - - - - - - - - - - - - - - - - -
To clean up the code you can delete or comment the BBCodeHelp fields and any BBCode related lines from both BlogEntry.php and BlogHolder.php and remove the Blog Management Widget ($managementwidget) in the requireDefaultRecords() method in BlogHolder.php
run /db/build/?flush=1 and the blog now hopefully uses the html editor and still provides the functionality of a blog summary. You loose the Blog Management Widget, but I can live with that.
Maybe I forgot a few minor adjustments, but it should be enough information to make it work.
Cheers!
Anatol