Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » Extending Blog Entries - Best Way?

Discuss the Blog Module.

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

Page: 1 2 3
Go to End
Author Topic: 3216 Views
  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    Ok, I haven't tested it but something like this would be how you do it.

    // add this to mysite/_config.php
    DataObject::add_extension('BlogEntry', 'CustomBlogEntry');

    // put this code in mysite/code/CustomBlogEntry.php
    <?php

    class CustomBlogEntry extends DataObjectDecorator {

    public function updateCMSFields(FieldSet &$fields) {
    $fields->removeFieldFromTab('Root','LeftSidebar'));
    $fields->removeFieldFromTab('Root','RightSidebar'));
    }
    }

  • DanStephenson
    Avatar
    Community Member
    115 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    Hi Willr,

    I tried the exact same thing shortly after I posted. I've got just what you posted (minus the extra closing brackets on the two removefieldfromtab lines), and it's still not working. I am very confused now.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    Perhaps try putting a die() statement in that function. Does it even get called?.

  • DanStephenson
    Avatar
    Community Member
    115 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    I tried that too, and the function is indeed being called.

    Now, my tabs for "Left Sidebar" and "Right Sidebar" were actually created on the Page datatype, which BlogEntry extends. That shouldn't matter, should it?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    Well the first thing is to work out why that decorator isn't being applied. I'm guessing you're done the usual admin/?flush=1 to flush the cache?

  • DanStephenson
    Avatar
    Community Member
    115 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    I've done a flush on both /admin/ and on /dev/build/

  • DanStephenson
    Avatar
    Community Member
    115 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    The guys on IRC are stumped too.

  • Ku$h
    Avatar
    Community Member
    14 Posts

    Re: Extending Blog Entries - Best Way? Link to this post

    Thanks for you help with that Willr, I managed to get it working with Subclassing the blog module in the end. (Had quite lot of changes to make.)

    3216 Views
Page: 1 2 3
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.