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?


Go to End
Reply


19 Posts   3346 Views

Avatar
DanStephenson

Community Member, 115 Posts

27 January 2010 at 4:44pm

I am looking to extend the CMS for the blog entries. I want to allow a few more fields (like a header image for example) when the user enters a blog entry, and remove some of the fields normally associated with the "Page" type, as they don't apply to my blog.

I know it's best not to add these in the blog module, so that when it gets upgraded, I won't lose my changes. What is the best way to extend this module?

Avatar
Ku$h

Community Member, 14 Posts

28 January 2010 at 9:07pm

I've need to do exactly the same thing, can anybody help us?

Avatar
Willr

Forum Moderator, 5513 Posts

28 January 2010 at 10:32pm

The best way to extend module / core functionality is to use decorators. http://doc.silverstripe.org/doku.php?id=dataobjectdecorator

Dan, To answer your specific issue - you should be able to customize the CMS within a decorator by using the updateCMSFields() function. See http://doc.silverstripe.org/doku.php?id=dataobjectdecorator#modifying_cms_fields

Avatar
DanStephenson

Community Member, 115 Posts

31 January 2010 at 8:00pm

Edited: 31/01/2010 8:17pm

Hi Willr,

That's all I needed to know. Where do I put my dataobjectdecorator code?

Avatar
Willr

Forum Moderator, 5513 Posts

31 January 2010 at 8:12pm

You can create a new file in mysite/code/ for the decorator.

Avatar
DanStephenson

Community Member, 115 Posts

31 January 2010 at 8:17pm

Edited: 31/01/2010 8:17pm

Can I remove fields/CMS tabs using the data decorator? If so, how (the documentation shows how to add fields only), and if not, what's the best way to do that?

Avatar
Willr

Forum Moderator, 5513 Posts

31 January 2010 at 8:22pm

Yes, as it says on the dataobjectdecorator page you can define a updateCMSFields(&$fields) function. You should be able to then call any of the usual cmsfields functions - http://doc.silverstripe.org/doku.php?id=getcmsfields

http://doc.silverstripe.org/doku.php?id=dataobjectdecorator#modifying_cms_fields

Avatar
DanStephenson

Community Member, 115 Posts

31 January 2010 at 10:15pm

Edited: 31/01/2010 10:26pm

Maybe I am doing it wrong, but I am trying to remove 2 tabs from my CMS for all blog entries, like this:

public function updateCMSFields(FieldSet &$fields) {
   $fields->removeByName("RightSidebar");
$fields->removeByName("LeftSidebar");
}

And nothing is happening. Can anyone tell me what I am doing wrong here?

Go to Top