Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

Extending Blog Entries - Best Way?


Go to End


19 Posts   6442 Views

Avatar
Willr

Forum Moderator, 5523 Posts

31 January 2010 at 10:25pm

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')); 
}
}

Avatar
DanStephenson

Community Member, 116 Posts

31 January 2010 at 10:35pm

Edited: 31/01/2010 10:39pm

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.

Avatar
Willr

Forum Moderator, 5523 Posts

31 January 2010 at 10:39pm

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

Avatar
DanStephenson

Community Member, 116 Posts

31 January 2010 at 10:41pm

Edited: 31/01/2010 10:47pm

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?

Avatar
Willr

Forum Moderator, 5523 Posts

31 January 2010 at 10:47pm

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?

Avatar
DanStephenson

Community Member, 116 Posts

31 January 2010 at 10:49pm

Edited: 31/01/2010 10:57pm

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

Avatar
DanStephenson

Community Member, 116 Posts

31 January 2010 at 11:26pm

The guys on IRC are stumped too. :(

Avatar
Pixel Labs

Community Member, 14 Posts

5 February 2010 at 9:04pm

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.)