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
DanStephenson

Community Member, 116 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
Pixel Labs

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, 5523 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, 116 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, 5523 Posts

31 January 2010 at 8:12pm

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

Avatar
DanStephenson

Community Member, 116 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, 5523 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, 116 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