Do we intend to help users embed forms on 3rd party sites?

For example, imagine a drupal powered commenting service like http://js-kit.com/. The service lets you add a comment feature to any web page. So we'd have to embed reading of comments (easy - use Views) and writing of comments (hard - requires some authentication). Would embed widgets help with the writing comments?

Comments

jtsnow’s picture

Yes, this is definitely a feature that I've planned on adding in the future. I haven't had time during Summer of Code to implement it.

moshe weitzman’s picture

OK, great. If you have any ideas on how you want it implemented, I may be able to help code it.

I have a client who needs to use Drupal for commenting/rating on his 3rd party CMS. So my use case is easier than most other embed scenarios - client owns both the source and the target web sites.

nedjo’s picture

Title: Embedded forms » Enable registration, authentication and form submission from widgets

Yes, the ability to register, authenticate, and submit other forms will be commonly needed.

It looks like the problem breaks down mainly to:

1. Embed forms in widgets--relatively easy.
2. Ensure form submission within widgets works as expected--relatively easy.
3. Control page loading so that page remains within the widget following form submission--a bit trickier.

For 3, the main problem is to override the standard handling of page redirection, which involves (a) a path returned by the last form submit handler, (b) $_REQUEST['destination'] setting, and (c) more perniciously, direct calls to drupal_goto().

A trick I've used in the past is to register a form submit handler and in the handler set $_REQUEST['destination']. That way, even if there is a later form submit handler that returns a path, the explicitly set destination will prevail.

freshaspect’s picture

This feature would be invaluable for various projects that we are working on at the moment. We are also happy to apply our resources to help out.

Most of the use cases that we are looking at match moshe's in that the client owns both the source and target web sites - and indeed could be hosted on different subdomains of the same primary domain, which would make cookie sharing easier. It all gets trickier when source and target are on different domains.

I will look into getting some detailed use cases together.

jtsnow’s picture

nedjo, For number 3 on your list, would something along the lines of this work?

function embed_widgets_form_alter(&$form, $form_state, $form_id) {
  if ($_REQUEST['embed_widgets_mode']) {
     $form['widget_mode'] = array(
        '#type' => 'hidden',
        '#value' => TRUE,
      );
  }
}

Then in hook_init(), check if $form['widget_mode'] was submitted. If it was, make sure a widget-compatible of the destination page is rendered.

patchak’s picture

I agree that this is a great feature. In my case, I would like to see users keep their login information when they browse from one site to another. When they would arrive to a site that already has the widget enabled, their login credentials would be recognized by the widget and they would be able to communicate with the main drupal site, directly from the widget. Is this already doable with the current code?

jtsnow’s picture

Yes, using the current code, your widgets will already recognize users who have logged in to your Drupal site. A widget is a page in the "main Drupal site," it's not a separate program that needs to communicate with the main site.

patchak’s picture

that's great, so I guess the new features are more related to passing info to the site, like voting on the current node (on the remote site) or tagging, etc??

Also, the supplemental work needed would be to allow users to actually login to the site and to register from the remote site ? Is it possible to implement that with pop ups for example so that the user nevers leaves the original site while registering or logging in on the site?

thanks again
Patchak

jtsnow’s picture

Version: 6.x-1.x-dev » 6.x-2.0-alpha1
Status: Active » Fixed

Latest version supports in-widget forms, but more thorough testing should be done. Post new issues as bugs are found.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.