You are here

function panels_sections_in_section in Panels Sections 6.2

Same name and namespace in other branches
  1. 6 panels_sections.module \panels_sections_in_section()

An API for modules that want to know about panels_sections.

This API is a function that lets you find out about sections.

Parameters

Optional $section a string containing the section you wnat to test against.:

Return value

Depends on the parameter. If you do not give $section, it will return the section object, if found. If you give $section, it will return TRUE if you are in that section Otherwise it will return FALSE

2 calls to panels_sections_in_section()
panels_sections_check_section in ./panels_sections.module
API to allow you to get a text string back with the name of the current section, or returns TRUE/FALSE if the section name passed in is the current section
panels_sections_takeover in ./panels_sections.module
This function must be called once from template.php it will determine which panel to use based by querying panels_page and panels_sections, then load the correct panel and do some text replacing to convert %CONTENT% to the page content so you can use…

File

./panels_sections.module, line 330
Allows you to define panels_sections of your site and apply s to those panels_sections.

Code

function panels_sections_in_section($section = NULL) {
  $output = FALSE;
  if (is_string($section)) {

    // caller wants to know if shes in the section she provided.
    if ($section == panels_sections_in_section()) {
      $output = TRUE;
    }
  }
  else {

    // caller wants to know in which section she is.
    $res = db_query("SELECT sid, name, path, status, visibility, panels_page, weight FROM {panels_sections_data} WHERE status=1 ORDER BY weight");
    while ($row = db_fetch_object($res)) {
      if ($row->visibility == 1) {

        // This bizarre bit of magic courtesy of block.module
        $path = drupal_get_path_alias($_GET['q']);
        $regexp = '/^(' . preg_replace(array(
          '/(\\r\\n?|\\n)/',
          '/\\\\\\*/',
          '/(^|\\|)\\\\<front\\\\>($|\\|)/',
        ), array(
          '|',
          '.*',
          '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
        ), preg_quote($row->path, '/')) . ')$/';
        if (preg_match($regexp, $path) && !($path == 'admin/block')) {
          $output = $row;
        }
      }
      else {
        if (drupal_eval($row->path)) {
          $output = $row;
        }
      }
    }
  }
  return $output;
}