1

Normally, a webform places the body content first and then the form after. I want to reverse it. I want the form to appear first and the body content to appear afterward. Is this possible?

  • You can expose your form in a block and then position in your blocks settings and place it before the content in admin/structure/block – cayerdis Jan 27 '15 at 15:03
  • When I refer to "body content", I meant the body content of the form, e.g. Go to the webform, then the Edit tab. I want the content there to show up before the form. – Jeff Jan 27 '15 at 15:13
  • In other words, I am not taking about the Main page content block but the actual body of the webform. – Jeff Jan 27 '15 at 15:21
4

In Drupal the content of a page view is created by a template file and $variables. The variables are typically a simple PHP string or Drupal7 render arrays when the content is more complex than just a string, and the system composes all the render arrays into page output.

A render array for instance can be a Webform, or a Node of a Page (content type). When you place Node ID 1 which contains a Webform reference the system is really composing these 2 items into your 1 page.

A single key per render array may be a #weight value this integer value denotes where this content appears from top to bottom among the many render arrays composed by the system within a given Region of the page.

Yes, it is possible to flip or change the ordering of the Body field and the Webform presentation to the visitor. Typically you would do this in the theme layer of drupal by implementing a Drupal hook to change the weight value in a render array.

If you don't want to code alot there are numerous modules that can let you change the display of items on the page with little or not coding. One example is Display Suite (otherwise known as DS). It allows you to override or customize view_modes of content on your site.

For example I have on a website the default Drupal content type of Page, and I've configured Webform to allow webforms to be placed on Page Nodes. Using DS I could change all webforms to appear before the Body of the Page Node in a simple administrative UI:

enter image description here

I leave it to you to do additional research to find the tool(s) you are comfortable with to complete your task. I've outlined at least 2 here (DS and core APIs).

EDIT

To be clear, if you're using Webform as a content type directly (and not attaching it other content types) DS may not show you "Body" and "webform" fields on the Webform content type -- but the webform Node is still just a render array and its fields still have #weight values. I find it more useful to attach webforms onto content, then to use Webforms by themselves.

  • This is great. Exactly what I needed. Thanks so much! – Jeff Jan 27 '15 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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