You are here

function prebid_preprocess_html in Doubleclick for Publishers (DFP) 7.2

Implements hook_preprocess_HOOK().

File

prebid/prebid.module, line 77

Code

function prebid_preprocess_html(&$variables) {
  if (($library = libraries_load('prebidjs')) && !empty($library['loaded'])) {

    // We need to load the prebid.dfp.js file after prebid.js but before
    // dfp_googletag.cmd.js from DFP. See _dfp_js_global_settings().
    // Get the settings from the prebid.js library.
    $options = $library['files']['js'][PREBID_JS_FILE];

    // Up the weight by one so we are after prebid.js.
    $options['weight'] += 1;

    // Load our custom javascript.
    drupal_add_js(drupal_get_path('module', 'prebid') . '/js/prebid.dfp.js', $options);
    ctools_include('bidder', 'prebid');
    $bidders = prebid_get_bidders();
    $settings = array(
      'prebidSettings' => array(
        'bidders' => $bidders,
        'buckets' => prebid_get_price_granularity(),
        'global' => prebid_get_global_settings(),
        'adUnits' => array(),
      ),
    );
    drupal_add_js($settings, 'setting');
  }
}