2

I'm trying to create a bookmarklet. This is not working:

javascript:window.location="http://domain.com/node/add/content_type?title="+encodeURIComponent(document.title)

The Prepopulate module is not ported for D7. Any recommendations?

1
  • 1
    I think you need some more detail here on what you're trying to accomplish.
    – jhedstrom
    Commented Jun 15, 2011 at 4:54

2 Answers 2

3

Out of the box, Drupal 7 doesn't support form population from the URL. Just like Drupal 6. That's why the Prepopulate module exists. Prepopulate is about 100 LoC, porting it to Drupal 7 is probably the best option. The effort has been started, see issue #935990.

2

As Pierre noted, the Prepopulate module is your way to go. I just installed it for Drupal 7 and it seems stable enough (works for the post title and body, anyway). The USAGE.txt that comes with it includes some info on using it for a bookmarklet for exactly this purpose.

However, I found that the code offered there didn't work for me: I had to change the variable name used for the body text from edit[body_field][body] to edit[body][und][0][value]. My guess is that this is because the site was previously upgraded from Drupal 6 to 7, but I can't say for sure.

Not to self-promote or anything, but I just published a long blog post about this, including the gotchas I found (like the variable name for the body field) and the version I wound up using: http://www.drupaldork.com/2011/08/mimicking-wordpress-press-bookmarklet-drupal-7

UPDATE September 11, 2011: I just released the QuickPost Bookmarklet module to add a frontend to make it easier to customize your bookmarklet. It requires Prepopulate, but it seems to be reasonably stable at this point—at least, for simple usage like this.

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.