Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Blog module doesn't use the standard HTML form?!

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2
Go to End
Author Topic: 5701 Views
  • darkowl
    Avatar
    Community Member
    12 Posts

    Blog module doesn't use the standard HTML form?! Link to this post

    Hi,

    I just noticed when using the blog module, that it doesn't support the standard HTML text entry (and TinyMCE editing capabilities) of a standard Silverstripe page. Instead, it opts for the insanity of having a BBcode parser?!

    My main concern with this is that the TinyMCE controls remain active, and it's very misleading to go and try to insert an image, only to have the JavaScript controls fail in an error because it can't find any target textarea controls to use.

    Given that this HTML editing ability seems to be a core part of the Silverstripe system, I would like to know why the blog ignores it and opts for a non-HTML BBcode solution instead? It seems almost counter-productive.

    I tried to do a little bit of hacking about to change the textarea from the BBcode one to a standard Silverstripe HTML one, and it worked okay in the admin, but saving resulted in a catastrophic failure which broke the blog posts on the public side.

    Is there any possibility that a future release of the blog module could scrap the BBcode and instead just use the HTML controls provided? It'd make life a lot more pleasant, I feel

  • DaveP
    Avatar
    Community Member
    48 Posts

    Re: Blog module doesn't use the standard HTML form?! Link to this post

    Hi Thanks for raising this - I was just about to enter a similar post

    Also I'm wondering why there is an inconsistency when entering links.

    If you right click on some highlighted text, and select Insert/Edit text you get a pop-up dialog to enter the details. If instead you click the hyperlink icon on the html toolbar, you get a Link section appear on the right to enter the details.

    Plus there are differences - e.g. the pop-up one has a class selection.

    regards, Dave Porter
    DJ Software

  • Anatol
    Avatar
    126 Posts

    Re: Blog module doesn't use the standard HTML form?! Link to this post

    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

  • perfectfool
    Avatar
    Community Member
    3 Posts

    Re: Blog module doesn't use the standard HTML form?! Link to this post

    Great summary, just one correction. The extra ContentMore field type in the $db array should be 'HTMLText', with no trailing comma:

    static $db = array(
       "Date" => "Datetime",
       "Author" => "Text",
       "Tags" => "Text",
       "ContentMore" => "HTMLText"
    );

  • asfahaan
    Avatar
    Community Member
    6 Posts

    Re: Blog module doesn't use the standard HTML form?! Link to this post

    Can someone post their edited and working files mentioned above? It would really help.

    Cheers,
    Asfahaan

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Blog module doesn't use the standard HTML form?! Link to this post

    If you don't want to use BBCode and want to revert to using TinyMCE you can add BlogEntry::allow_wysiwyg_editing();

  • Anatol
    Avatar
    126 Posts

    Re: Blog module doesn't use the standard HTML form?! Link to this post

    Hi willr,

    thank you for that hint. This new option is great!

    Please note that as I am writing this you need the latest daily build of the blog module (http://dailybuilds.silverstripe.com/modules-tarballs/), not the version in the regular download section.

    You may also need to make a little change in the template file, e.g. I am using the Olive Sunset template and had to change
    $Content.Parse(BBCodeParser)
    into
    $ParsedContent
    in the file BlogEntry.ss (in the olivesunset_blog section).

    A similar change is necessary in the BlogSummary.ss file.

  • fgalopo
    Avatar
    Community Member
    1 Post

    Re: Blog module doesn't use the standard HTML form?! Link to this post

    Hi,

    I'm a fresh new user of SilverStripe (what a great cms!), everything's fine, only one issue with the blog module:

    I'm using the latest build of the module (05/18/2008), with the "BlogEntry::allow_wysiwyg_editing('true');" option and the vista theme.
    I can add the entry using the html editor, when I view the post on the summary it's displayed ok, but when I try to view the full post (using the "read the full post" button):
    the post is displayed with the full html code (without interpreting it).

    What (and where) do I need to change the code to make it work?

    Thanks a lot for your help,
    FG

    5701 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.