i needed a way to prepopulate fields but not be blatantly obvious about it, so i figured i'd share how i did it.

insert the following at line 35 of prepopulate.module:

  // get base64encoded prepopulate values
  if (variable_get('prepopulate_allowed_' . $type, TRUE) && $_GET['pp']) {
  	parse_str(base64_decode($_GET['pp']),$_GET);
  } 

this allows you to base64 encode a query string and pass it to the page as ?pp=

for example, if you have the query string:

  $query = 'edit[title]=' . urlencode($titlestring) . '&edit[body]=' . urlencode($bodystring)

you can encode it like this:

  $encoded_query = 'pp=' . base64_encode($query);

resulting in a hideously long and not so blatantly obvious prepopulating query :)

Comments

add1sun’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

If this goes in, it will need to be option that is off by default and can be turned on in the settings, with a reasonable explanation of what it is and why you'd use it. This would also go in the D6 version 2 of the module.

bobthecow’s picture

I think the beauty of this is that it's "off" by default. unless someone creates a url with "pp=XXX" and adds a base64 encoded value, it will do nothing. Adding a configuration option to disable this might be a bit overkill.

Perhaps mentioning it in the documentation as an available option (along with a use case and example) would be enough?

add1sun’s picture

Ahh gotcha, for some reason I completely blew by the && $_GET['pp'] in there. :p I'll add this to the module in the V2 that's a-coming. I probably won't get time for that for a few weeks.

jbrauer’s picture

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

This got added but the issue wasn't closed out.

dennys’s picture

I just tested it in 2.1, it's great, thanks. The generated URL will like the following one, don't forget to put "node/add/transaction?" in the URL

http://example.com/node/add/transaction?pp=ZWRpdFt0aXRsZV096Zu76LK7JmVkaXRbZml...

Status: Fixed » Closed (fixed)

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

giorgio79’s picture

Version: » 6.x-2.x-dev
Status: Closed (fixed) » Active

This is some great stuff.

Could we have a bit more control over this in admin?

I would only like to encode only the actual value, instead of the entire query string like this


http://example.com/node/add/transaction?edit[title]=ZWRpdFt0aXRsZV096Zu76LK7JmVkaXRbZml...

jbrauer’s picture

Status: Active » Closed (fixed)

Please open new issues as new requests instead of re-opening closed issues.