1

I'm relatively new to Drupal and I'm working on a page that needs comment functionality for non-authenticated users. I tried some various forms (Webform, EntityForm) but they just seemed like way too much. The comments module has exactly what I need as far as submission and moderation goes.

I tried adding the form to the sidebar of a page but it showed up with a massive rich text editor and kind of broke the layout.

Is it possible to insert a very basic comment form with a simple long-text field and a submit button? If so...how?

Screenshot:enter image description here

1
  • Where's your Rich text editor coming from? That's not there by default on Drupal. If you're using WYSIWYG then all you need to do is configure permissions to disallow Anonymous users from accessing any Text format except the "Plain text". Then go to WYSIWYG profiles and set "Plain text" to "No editor". Then they won't get rich text editors anywhere (even though you're getting one when you're logged in).
    – Beebee
    Commented Mar 27, 2015 at 17:01

5 Answers 5

1

You may use Panels module.

Using that you can place comment form any where as your specification.

For more info go through project documentation .

0

Maybe provide a Screenshot of that broken Layout, and how did you get the form to show up on in the sidebar? (there are various ways)

Comments are tight to nodes, you can modifiy the fields of a comment if you edit the specific content type that is commented on, e.g. remove title, and only have a long text field.

Furthermore for the editor itself: Drupal comes with a few basic text formats: plaintext, filtered html and full html. You can modify the display and features of each, e.g. create a comment text filter and limit it to plaintext or reuse the already existing plaintext filter, afterwards you should limit anonymous users to only be allowed to use this specific filter (that removes the whole stuff about switching text formats as well).

For more answers you should ask more specific questions.

2
  • I added a screenshot of the sidebar. I added it through Panelizer > Add Content > Comment section. I would ideally like to remove any mention of "rich text" and editor controls for non authenticated users. It's also adding two comment forms and I'm not sure why.
    – Vecta
    Commented Mar 27, 2015 at 17:10
  • regarding the rich text stuff and text formats I already posted something. to hide the tips see drupal.stackexchange.com/questions/36829/… Commented Mar 27, 2015 at 17:31
0

Use this code to load the form

$comment = new stdClass;
$comment->nid = $nid;
$form = drupal_get_form('comment_form', $comment);

and then display the $form in the sidebar

0

You can use hook_form_alter() to modify the form fields.

0

I had a similar problem in that I was programmatically creating an 'answer' node per question. Also needed to have ability to comment on that answer. Drupalist's answer to programmatically creating a comment helped a lot:

$comment = new stdClass;
$comment->nid = $nid;
$form = drupal_get_form('comment_form', $comment);

More details on programmatically creating comments at https://www.drupal.org/node/1030676#comment-6305154

I also had to make sure that each instantiated answer (node) had:

'comment' => 2,

which allows the programmatically created node to be open for comments (2 = read/write, 1 = read only, 0 = closed)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.