You are here

function context_init in Context 6

Same name and namespace in other branches
  1. 6.3 context.module \context_init()
  2. 6.2 context.module \context_init()
  3. 7.3 context.module \context_init()

Implementation of hook_init().

File

./context.module, line 139

Code

function context_init() {

  // context integration against the sitewide setter
  context_set_by_condition('sitewide', 1);

  // context integration against paths
  $path = array();
  $path['real'] = $_GET['q'];
  $path['alias'] = drupal_get_path_alias($_GET['q']);
  if ($path['real'] == $path['alias']) {
    unset($path['alias']);
  }

  // Test each path option incrementally adding args as we go.
  foreach ($path as $path_option) {
    $args = explode('/', $path_option);
    if (count($args)) {
      $test = array_shift($args);
      context_set_by_condition('path', $test);
      while (count($args)) {
        $test .= '/' . array_shift($args);
        context_set_by_condition('path', $test);
      }
    }
  }
}