You are here

function panels_sections_check_section in Panels Sections 6.2

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

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

This is the functionality I thought panels_sections_insection should provide, rather than returning an object with everything but the section name. I wrote this function leveraging rather than rewriting panels_sections_in_section.

Parameters

Optional $section_to_match a string containing the section name: you want to test against

Return value

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

File

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

Code

function panels_sections_check_section($section_to_match = NULL) {

  //get section object
  $section_row = panels_sections_in_section();

  //get section from object
  $section = $section_row->name;
  if (is_string($section_to_match)) {

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

    //else return the section name
    $return_value = $section;
  }
  return $return_value;
}