I'm using Domain Access to manage several domains, and I wanted to use the twitter module.
The twitter setup global account should set a different twitter account for each domain, but I can't see how to setup, each time I change from any domain, changes are rolled out for all domains.
I tried to use the Domain_prefix (copy, create) to see if I could split the info, but same results.

Are both modules compatible?
Anyone using both modules with differents twitter account ?

Thanks,
Pedro.

Comments

agentrickard’s picture

Assuming all the Twitter data is stored as variables, then use hook_domainconf() or hook_domainbatch(), as documented in API.php. If Twitter module stores its info in a database table, table prefixing should work.

If, however, it does _both_, then you need a custom bridge module.

pedrosp’s picture

I created yesterday the file domain_conf.inc to solve the Google Analytics workaround with Domain access, and it works fine.
I tried then to do "the same" (i'm a newbie) for twitter module, below the code used, but I can't see any twitter module related fields to setup on the domain settings. (I can still see the GAnalytics one).

Any help much appreciated.
Pedro

/**
* Implements hook_domainconf() to add the google analytics account number per domain.
*/

function googleanalytics_domainconf() {
  $form['googleanalytics'] = array(
    '#type' => 'fieldset',
    '#title' => t('Google Analytics settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['googleanalytics']['googleanalytics_account'] = array(
    '#type' => 'textfield',
    '#title' => t('Google Analytics account number'),
    '#default_value' => variable_get('google_analytics', 'UA-'),
    '#size' => 15,
    '#maxlength' => 20,
    '#required' => TRUE,
    '#description' => t('The account number is unique to the websites domain. Click the <strong>Edit</strong> link in your Google Analytics account next to the appropriate profile on the <strong>Analytics Settings</strong> page, then select <strong>Check Status</strong> at the top-right of the table to find the account number (UA-xxxx-x) of your site. You can obtain a user account from the <a href="@url">Google Analytics</a> website.', array('@url' => 'http://www.google.com/analytics/')),
  );
  return $form;
}
/**
* Implements hook_domainconf() to add the setup of a global twitter account per domain.
*/

function twitterglobalaccount_domainconf() {
  $form['global_account'] = array(
    '#type' => 'fieldset',
    '#title' => t('Global Twitter account'),
    '#description' => t('A site-wide Twitter account to use as the default when tweets are posted. This is useful for single-user blogs or sites where many users post to a single shared Twitter account.'),
  );

  $form['global_account']['twitter_global_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Twitter user name'),
    '#default_value' => variable_get('twitter_global_name', NULL),
  );
  
  $form['global_account']['twitter_global_password'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#description' => t("If your Twitter account is protected, or you wish to post to Twitter from Drupal, you must enter the Twitter account's password."),
    '#default_value' => variable_get('twitter_global_password', NULL),
  );

  $form['posting']['twitter_default_format'] = array(
    '#type' => 'textfield',
    '#title' => t('Default format string'),
    '#maxlength' => 140,
    '#description' => t('The given text will be posted to twitter.com. You can use !url, !url-alias, !tinyurl, !title, and !user as replacement text.'),
    '#default_value' => variable_get('twitter_default_format', 'New post: !title !tinyurl'),
  );

  return $form;
}
agentrickard’s picture

The name of the hook has to match the name of the module. Assuming you're using http://drupal.org/project/twitter, you must name the hook: twitter_domainconf()

You can also submit that function as a patch to Twitter module. The domain_conf.inc trick is there as a stopgap if people don't commit your hook patch.

agentrickard’s picture

You should also change the form fieldset name to avoid namespace problems:


function twitter_domainconf() {
  $form['twitter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Global Twitter account'),
    '#description' => t('A site-wide Twitter account to use as the default when tweets are posted. This is useful for single-user blogs or sites where many users post to a single shared Twitter account.'),
  );

  $form['twitter']['twitter_global_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Twitter user name'),
    '#default_value' => variable_get('twitter_global_name', NULL),
  );
 
  $form['twitter']['twitter_global_password'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#description' => t("If your Twitter account is protected, or you wish to post to Twitter from Drupal, you must enter the Twitter account's password."),
    '#default_value' => variable_get('twitter_global_password', NULL),
  );

  $form['twitter']['twitter_default_format'] = array(
    '#type' => 'textfield',
    '#title' => t('Default format string'),
    '#maxlength' => 140,
    '#description' => t('The given text will be posted to twitter.com. You can use !url, !url-alias, !tinyurl, !title, and !user as replacement text.'),
    '#default_value' => variable_get('twitter_default_format', 'New post: !title !tinyurl'),
  );

  return $form;
}
pedrosp’s picture

Status: Active » Fixed

Thanks agentrickard
It works fine, just for the record I copy the final code with some minor changes. Posted also on #611698: Twitter module compatible with domain access ?

/**
* Implements hook_domainconf() to add the google analytics account number per domain.
*/

function googleanalytics_domainconf() {
  $form['googleanalytics'] = array(
    '#type' => 'fieldset',
    '#title' => t('Google Analytics settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  $form['googleanalytics']['googleanalytics_account'] = array(
    '#type' => 'textfield',
    '#title' => t('Google Analytics account number'),
    '#default_value' => variable_get('google_analytics', 'UA-'),
    '#size' => 15,
    '#maxlength' => 20,
    '#required' => TRUE,
    '#description' => t('The account number is unique to the websites domain. Click the <strong>Edit</strong> link in your Google Analytics account next to the appropriate profile on the <strong>Analytics Settings</strong> page, then select <strong>Check Status</strong> at the top-right of the table to find the account number (UA-xxxx-x) of your site. You can obtain a user account from the <a href="@url">Google Analytics</a> website.', array('@url' => 'http://www.google.com/analytics/')),
  );
  return $form;
}
/**
* Implements hook_domainconf() to add the setup of a global twitter account per domain.
*/

function twitter_domainconf() {
  $form['twitter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Twitter Global Account'),
    '#description' => t('A site-wide Twitter account to use as the default when tweets are posted. This is useful for single-user blogs or sites where many users post to a single shared Twitter account.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,

  );

  $form['twitter']['twitter_global_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Twitter Domain User name'),
    '#default_value' => variable_get('twitter_global_name', NULL),
  );
  
  $form['twitter']['twitter_global_password'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#description' => t("If your Twitter account is protected, or you wish to post to Twitter from Drupal, you must enter the Twitter account's password."),
    '#default_value' => variable_get('twitter_global_password', NULL),
  );

  $form['twitter']['twitter_default_format'] = array(
    '#type' => 'textfield',
    '#title' => t('Default format string'),
    '#maxlength' => 140,
    '#description' => t('The given text will be posted to twitter.com. You can use !url, !url-alias, !tinyurl, !title, and !user as replacement text.'),
    '#default_value' => variable_get('twitter_default_format', 'New post: !title !tinyurl'),
  );

  return $form;
}

Status: Fixed » Closed (fixed)

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

Exploratus’s picture

My guess is this is already insidde the twitter module??? I downloaded Twitter Module, and Domain Access works right out of the box.... Or am I missing something?

Cheers.