You are here

function fb_example_preprocess_page in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 contrib/fb_example.module \fb_example_preprocess_page()

Implements hook_preprocess_page().

Under admin >> site building >> facebook apps >> canvas pages, you'll find some settings regarding the "processing" of canvas pages. This processing changes links for the entire page, so that all links point to http://apps.facebook.com/... instead of Drupal's normal base_url.

If instead you only want some of the links on a page to work this way, and leave some unmodified, you can take the approach shown here. In this hook we process the text in some regions of the page, but not all. So for example links in the normal 'content' will not be modified.

The code shown here could also be located in your theme's preprocess function, or even in a page template.

Note this function is only relavent when the checkboxes on admin >> site building >> facebook apps >> canvas pages are disabled.

File

contrib/fb_example.module, line 413
Example customizations to modules/fb.

Code

function fb_example_preprocess_page(&$variables) {
  if (module_exists('fb_canvas') && fb_is_canvas()) {
    include_once drupal_get_path('module', 'fb') . '/fb.process.inc';

    // Process links in these regions.
    $regions = array(
      'content',
      'header',
      'footer',
      'left',
      'preface_first',
      'preface_middle',
      'preface_last',
    );
    foreach ($regions as $region) {
      $variables[$region] = fb_process($variables[$region], array(
        'add_target' => '_top',
        'absolute_links' => TRUE,
      ));
    }
  }
}