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.

Blog Module

Discuss the Blog Module.

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

Extending Blog Entries - Best Way?


Reply

19 Posts   3287 Views

Avatar
Willr

31 January 2010 at 10:25pm Forum Moderator, 5511 Posts

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

31 January 2010 at 10:35pm (Last edited: 31 January 2010 10:39pm), Community Member, 115 Posts

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

31 January 2010 at 10:39pm Forum Moderator, 5511 Posts

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

Avatar
DanStephenson

31 January 2010 at 10:41pm (Last edited: 31 January 2010 10:47pm), Community Member, 115 Posts

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

31 January 2010 at 10:47pm Forum Moderator, 5511 Posts

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

31 January 2010 at 10:49pm (Last edited: 31 January 2010 10:57pm), Community Member, 115 Posts

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

Avatar
DanStephenson

31 January 2010 at 11:26pm Community Member, 115 Posts

The guys on IRC are stumped too. :(

Avatar
Ku$h

5 February 2010 at 9:04pm Community Member, 14 Posts

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