Has anyone looked at handling modules such as recaptcha and gmap with regard to the domain specific keys?

I'm guessing domain prefix is the obvious choice unless you edit the original module?

If patching the original module, any recommendations for how to go about doing it for domain?

Comments

scedwar’s picture

Hmmm. This looks like a good step forward:
http://drupal.org/project/keys_api

agentrickard’s picture

Please do not hack or patch the core module.

The Domain module has an internal API for new features, and it was designed for just this situation. You should consider writing a small extension module -- or encouraging it as a patch to the other modules.

You want to use Domain Conf in most cases, extended by hook_domainconf. This will work for any module that stores its settings in the {variables} table.

In the sample code, the default user picture is changed for each subdomain. You can do the same for gmap

If the module uses its own database tables, then Domain Prefix is the correct answer, and no hacking is necessary.

However, there are instances, such as with Forums, where modules use both database tables and {variables}. These cases do not have a general solution yet, and must be considered on a case-by-case basis.

I looked at the modules mentioned. Gmap and Recaptcha use the {variables} table exclusively and should be extensible using hook_domainconf.

agentrickard’s picture

http://drupal.org/project/keys_api is interesting, but I don't think it solves your problem -- though it might.

scedwar’s picture

Thanks - that was just the info I needed.

When I said "patching the original module" I meant, for example, patching gmap to be domain module aware using your hooks.

keys_api could be a more elegant solution that hopefully all module developers with api keys would adopt.

agentrickard’s picture

Status: Active » Closed (fixed)

Got it. I looked briefly at keys_api, and it doesn't quite work with Domain (due to the variables/table mixture).

scedwar’s picture

Version: 5.x-1.0 » 5.x-1.1beta

I've just been trying this out with beta1 and all seems fine. Am I missing the problem, or have you slipped this in to the new release? :-)

scedwar’s picture

And this code also appears to work for setting recaptcha keys: http://drupal.org/node/150100#comment-775278

agentrickard’s picture

I don't understand comment #6.

http://drupal.org/node/150100#comment-775278 is fine if you are not using Domain Configuration module. If you are. it would be better to implement hook_domainconf(). Otherwise, you end up running similar lookup code multiple times.

scedwar’s picture

You said: "I looked briefly at keys_api, and it doesn't quite work with Domain (due to the variables/table mixture)."
I said: "I've just been trying this out with beta1 and all seems fine. Am I missing the problem?"

My point is that keys_api appears to be working with domain although I haven't done extensive testing. What are the issues that cause you to say "it doesn't quite work"?

Thanks, Stephen

agentrickard’s picture

I have not tested keys_api. My concern, simply from looking at the code, is that the table storage may complicate the use of Domain Conf.

If there is no conflict, that's great, but I have not made any changes to accommodate keys_api.

Memeshift’s picture

Project: Domain » GMap Module
Version: 5.x-1.1beta » 5.x-1.x-dev
Component: Code » Miscellaneous

Keep in mind that when working with subdomains you'll need to generate a SEPARATE Google API Map key for each site.

For instance if you have TWO Drupal installs, like one in the root and one in a directory with a sub domain, you'll need TWO API Keys.

i.e. one key for http://www.sandbox.mywebsite.com
and another key for http://www.mywebsite.com

I just figured this out pretty quickly, but for those who get stuck...

-morgan

agentrickard’s picture

For integrating these types of features into Domain Access, see http://therickards.com/api/function/hook_domainconf/Domain

duellj’s picture

I ran into this very problem with my multi-domain setup with the Domain module. Here's an implementation of hook_domainconf that fixes the problem:


/**
 * Implementation of hook_domainconf().
 *
 * See http://therickards.com/api/function/hook_domainconf/Domain
 *
 * Adds support for per domain Google Map keys
 */
function test_domainconf() {
  $form['gmap'] = array(
    '#type' => 'fieldset',
    '#title' => t('Google Maps'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['gmap']['googlemap_api_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Google Maps API Key'),
    '#default_value' => variable_get('googlemap_api_key', ''),
    '#size' => 50,
    '#maxlength' => 255,
    '#description' => t('Your personal Googlemaps API key.  You must get this for each separate website at <a href="http://www.google.com/apis/maps/">Google Map API website</a>.'),
  );

  return $form;
}
agentrickard’s picture

Exactly.

Anonymous’s picture

I need multiple Google Maps API keys for my sites and am trying to implement this, but must be doing something wrong...

I've put the code from #13 into my template.php file (I'm assuming that's where it goes), but cannot find where to add extra API keys.
I've looked in the GMap settings, Domain-specific settings and batch update settings but can't see anything...

agentrickard’s picture

You can't put it in template.php, that is too late.

It either needs to go in a custom module file (which is what #13 does), or you can create the following file:

[your modules directory] > domain > domain_conf > domain_conf.inc

See section 4.2 Using domain_conf.inc of the Domain Conf README.txt file.

Anonymous’s picture

Thanks, creating a domain_conf.inc file did the trick.
Had to rename the function to 'gmap_domainconf()', but that wasn't too hard ;)

I'll see about adding this to the GMap module...