1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Extending Blog Entries - Best Way?
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 2649 Views |
-
Extending Blog Entries - Best Way?

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?
-
Re: Extending Blog Entries - Best Way?

28 January 2010 at 9:07pm
I've need to do exactly the same thing, can anybody help us?
-
Re: Extending Blog Entries - Best Way?

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
-
Re: Extending Blog Entries - Best Way?

31 January 2010 at 8:00pm Last edited: 31 January 2010 8:17pm
Hi Willr,
That's all I needed to know. Where do I put my dataobjectdecorator code?
-
Re: Extending Blog Entries - Best Way?

31 January 2010 at 8:12pm
You can create a new file in mysite/code/ for the decorator.
-
Re: Extending Blog Entries - Best Way?

31 January 2010 at 8:17pm Last edited: 31 January 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?
-
Re: Extending Blog Entries - Best Way?

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
-
Re: Extending Blog Entries - Best Way?

31 January 2010 at 10:15pm Last edited: 31 January 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?
| 2649 Views | ||
| Go to Top | Next > |


