0

I'm looking for a way to have a disclaimer page/popup be a part of creating a certain type of content, in this case a OG group. Is this something that could somehow be done with Webforms?

I found http://drupal.org/project/legal but it just doesn't quite do the trick... Any other ideas? :)

0

One way to accomplish this would be to make a small custom module utilizing hook_form_alter(). Substitute "example" with your module name to implement.

example.module

/**
* Implementation of hook_form_alter()
* Add Disclaimer Message to Article Create Form
*/
function example_form_article_node_form_alter(&$form, $form_state) {
  if (arg(1) == 'add') {
    drupal_set_message('Legal Disclaimer: By filling out this form you are agreeing.','warning');
  }
}

example.info

name = "Example module"
description = "Adds a disclaimer to node/add/article page."
package = Example
core = 7.x

Or if you want a popup, you could instead use drupal_add_js and a little Javascript

example.module

/**
* Implementation of hook_form_alter()
* Add Popup Disclaimer to Article Create Form
*/
function example_form_article_node_form_alter(&$form, $form_state) {
  if (arg(1) == 'add') {
    drupal_add_js(drupal_get_path('module', 'example').'example.js');
  }
}

example.js

// if user agrees continue, else redirect
if (!window.confirm('Legal Disclaimer: Press OK if you agree.')) {
  window.location.href='http://example.com';
}

Of course this is all pretty simple and ugly. One could combine both approaches and using CTools Modal or JQueryUI build a prettier dialog. With JQueryUI you might do:

example.js

// if user agrees continue, else redirect using JQueryUI
// requires JQueryUI loaded (you can use [drupal_add_js()][5] for this too).
(function ($) { 
  $(document).ready( function() {
    $("<div><h3>Legal Disclaimer</h3><p>Do you agree?</p></div>").dialog({
      resizable: false,
      height:140,
      modal: true,
      buttons: {
        "I Agree": function() {
          $( this ).dialog( "close" );
        },
        "No Way": function() {
          $( this ).dialog( "close" );
          window.location.href='http://example.com';
        }
      }
    });
  });
});

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.