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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Add fields to PageComments form?


Go to End


9 Posts   5769 Views

Avatar
drye

Community Member, 49 Posts

4 January 2010 at 8:36pm

Edited: 05/06/2010 2:56pm

EDIT: Just to update this "answer" I wrote a tutorial on SSbits (http://ssbits.com/adding-fields-to-page-comments/) - Hope it helps

@MarijnKampf

Let me explain what I have done, in my examples I am adding an email field. Also note that while this does manage to add the field the the CMS CTF (Complex Table Field) it fails to add it to the popup.

Here goes:
File added - CommentAdminDecorator.php (in mysite directory)

<?php

/*Copied EditForm from CommentAdmin.php version 2.3.1
    - Added Email field
 */
class CommentAdminDecorator extends LeftAndMainDecorator  {
    
    public function Link(){ //had to add errors out as missing function if not
        return $this->owner->Link();
    }
	
	public function MyEditForm() {//Was originally EditForm, wasn't showing in the template so I had to create my own template
......
		$tableFields = array(
			"Name" => _t('CommentAdmin.AUTHOR', 'Author'),
			"Comment" => _t('CommentAdmin.COMMENT', 'Comment'),
			"CommenterEmail" => _t('CommentAdmin.COMMENTEREMAIL', 'Email'),
			"PageTitle" => _t('CommentAdmin.PAGE', 'Page'),
			"CommenterURL" => _t('CommentAdmin.COMMENTERURL', 'URL'),
			"Created" => _t('CommentAdmin.DATEPOSTED', 'Date Posted')
		);	
		
		$popupFields = new FieldSet(
			new TextField('Name', _t('CommentAdmin.NAME', 'Name')),
			new TextField('CommenterEmail', _t('CommentAdmin.COMMENTEREMAIL', 'Email')),
			new TextField('CommenterURL', _t('CommentAdmin.COMMENTERURL', 'URL')),
			new TextareaField('Comment', _t('CommentAdmin.COMMENT', 'Comment'))
		);
......
	}
}
?>

File added - CommentAdmin_right.ss (in templates/Includes)
<div id="form_actions_right" class="ajaxActions">
</div>

<% if MyEditForm %>
	$MyEditForm
<% else %>
	<form id="Form_EditForm" action="admin/comments?executeForm=EditForm" method="post" enctype="multipart/form-data">
		<p><% _t('WELCOME1', 'Welcome to the') %> $ApplicationName <% _t('WELCOME2', 'comment management. Please select a folder in the tree on the left.') %></p>
	</form>
<% end_if %>

<p id="statusMessage" style="visibility:hidden"></p>

I hope this helps! If anyone comes up with why my popup isn't picking up the field please let me know!

-Dan

Go to Top