You are here

function theme_ad_external_ad in Advertisement 6.2

Same name and namespace in other branches
  1. 6.3 external/ad_external.module \theme_ad_external_ad()
  2. 6 external/ad_external.module \theme_ad_external_ad()
  3. 7 external/ad_external.module \theme_ad_external_ad()

Return a themed ad of type ad_remote.

Parameters

@ad: The ad object.

Return value

A string containing the ad markup.

1 theme call to theme_ad_external_ad()
ad_external_display_ad in external/ad_external.module
Function used to display the selected ad.

File

external/ad_external.module, line 30
Enhances the ad module to support externally hosted ads, served via IFrames. It is recommended that you configure "Administer >> Content management >> Ads >> Settings >> Global settings >> Display type" to…

Code

function theme_ad_external_ad($ad) {
  global $base_url;
  if (isset($ad->aid)) {
    $output = '<div class="external-advertisement" id="ad-' . $ad->aid . '">';

    // For now, we hard code this to only support caching with the file cache.
    // As more cache types are introduced, we'll expand this.  Ideally it should
    // be cache type agnostic, but that seems to be unrealistic.
    if (variable_get('ad_cache', 'none') == 'file') {
      $adserve = variable_get('adserve', '');
      $display_variables = '&amp;c=file' . module_invoke('ad_cache_file', 'adcacheapi', 'display_variables', array());
      $external = url("{$base_url}/{$adserve}?o=external&amp;n={$ad->aid}&amp;{$display_variables}");
    }
    else {
      $external = db_result(db_query('SELECT url FROM {ad_external} WHERE aid = %d', $ad->aid));
    }
    $append = 'frameborder="' . variable_get('ad_iframe_frameborder', 0) . '" ';
    $append .= 'scrolling="' . variable_get('ad_iframe_scroll', 'auto') . '" ';
    if ($height = variable_get('ad_iframe_height', '')) {
      $append .= "height=\"{$height}\" ";
    }
    if ($width = variable_get('ad_iframe_width', '')) {
      $append .= "width=\"{$width}\" ";
    }
    $output .= "<iframe src=\"{$external}\" {$append}></iframe>";
    $output .= '</div>';
    return $output;
  }
}