941 Posts in 272 Topics by 292 members
Forum Module
SilverStripe Forums » Forum Module » Extend ForumRole
Discuss the Forum Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 900 Views |
-
Extend ForumRole

26 October 2010 at 1:26am Last edited: 26 October 2010 1:27am
Hi, I'm trying to extend the ForumRole as described here http://doc.silverstripe.org/modules:forum.
However with the code below (and DataObject::add_extension('Member', 'CustomForumRole'); in _config.php), the form on the front-end (ForumMemberProfile/edit) is not being updated
<?php
class CustomForumRole extends DataObjectDecorator {
function extraStatics() {
return array(
'db' => array(
'CustomDatabaseField' => 'Text',
)
);
}
function getForumFields() {
$fieldset = new FieldSet(
new TextareaField('CustomDatabaseField')
);return $fieldset;
}
function updateCMSFields(&$fields) {$tabset = $fields->findOrMakeTab('Root.Main');
$tabset->push(new TextareaField('CustomDatabaseField'));}
}
?>What is missing?
-
Re: Extend ForumRole

28 October 2010 at 12:52am Last edited: 28 October 2010 12:53am
I don't think the getForumFields function is actually being called from ForumMemberProfile. Not sure why not. The extra field is being added to the CMS Member section.
function getForumFields($showIdentityURL, $addmode) {
Debug::Show("HI");
$fieldset = parent::getForumFields($showIdentityURL, $addmode);$fieldset.push(new FieldSet(new TextareaField('CustomDatabaseField')));
return $fieldset;
}The show debug code is never executed in my test.
-
Re: Extend ForumRole

30 October 2010 at 2:19am Last edited: 30 October 2010 2:33am
Thanks Marijn, you're right! Means that the Forum documentation is not correct http://doc.silverstripe.org/modules:forum.
It should be:
<?php
class CustomForumRole extends DataObjectDecorator {
function extraStatics() {
// To modify the fields of the database
}function updateForumFields() {
// To modify the forum member form (registration) of the forum
}function updateCMSFields() {
// To modify the forum member view of the popup window in the CMS part
}
}
?> -
Re: Extend ForumRole

30 October 2010 at 2:59am
Ok, here it is (special thanks to Martijn and Marijn):
<?php
// mysite/code/CustomForumRole.php
class CustomForumRole extends DataObjectDecorator {
function extraStatics() {
return array(
'db' => array(
'CustomField' => 'Text'
)
);
}function updateForumFields(FieldSet $fields) {
// Add CustomField to Frontend
$fields->push(new TextField('CustomField'));
return $fields;}
public function updateCMSFields(FieldSet $fields) {
// Add CustomField to CMS
$fields->addFieldToTab('Root.Main',new TextField('CustomField));
return $fields;}
}?>
-
Re: Extend ForumRole

30 October 2010 at 3:20am
Was just about to add a comment to the documentation, but saw that you beat me to it
-
Re: Extend ForumRole

30 October 2010 at 6:31pm
The documentation *is* a wiki which does allow you to edit the actual page content yourself so feel free to fix bugs as you find them.
-
Re: Extend ForumRole

30 October 2010 at 10:42pm
I did try to edit the page, but all I saw was: "This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. "
| 900 Views | ||
|
Page:
1
|
Go to Top |



