0

I am using Answers 7.x-4.0-rc2. Out of the box, the add answer form for a question is at the bottom of the page. I would like to be able to add this form to a block and put it on the left so that in mobile, it will appear at the top and on a regular screen, it will appear at the left.

I am already using Form Block in other places on the site so I tried that first. I enabled the add answers node form to become a block and placed it to the left sidebar. This created some sort of infinite loop of page not founds. I tailed watchdog to see endless reports of the answer node page not being found once it was loaded. Simple solution but didn't work for complex reasons.

The answers form is attached to the question node via the main theme template, sites/all/modules/contrib/answers/theme/node--answers.tpl.php for the answers module:

<?php if(isset($content['new_answer_form'])): ?>
    <div class="new-answer-form">
      <?php print render($content['new_answer_form']); ?>
    </div>
  <?php endif;?>

I was able to create a subtheme based on a modification to this theme template in which I moved the add answers form to the top of the page instead of the bottom but am still looking for a way to put it on the left for non-mobile via a block or some other act of Drupal magic. Any feedback is appreciated.

  • I am not using panels and do not wish to install it.
  • I tried the form block method with and without the form also being attached to the question page via the template
3
  • 2
    Probably easier to just create a custom module, implement the proper block hooks to define block, and provide the form to the block via drupal_get_form. I have done this many, many times. I don't know all of what Form Block does, but it should be a fairly straightforward thing to do in code and shouldn't result in a redirect loop.
    – Kevin
    Aug 11, 2017 at 0:32
  • yeah try, $form = drupal_get_form('new_answer_form', $nid); print drupal_render($form);
    – No Sssweat
    Aug 11, 2017 at 1:22
  • to get the $nid see this answer
    – No Sssweat
    Aug 11, 2017 at 3:51

0

Your Answer

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

Browse other questions tagged or ask your own question.