Index: sections.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/sections/sections.module,v retrieving revision 1.16.2.8 diff -u -p -r1.16.2.8 sections.module --- sections.module 13 Oct 2007 20:47:24 -0000 1.16.2.8 +++ sections.module 14 Feb 2008 23:26:25 -0000 @@ -330,7 +330,7 @@ function sections_in_section($section = } else { // caller wants to know in which section she is. - $res = db_query("SELECT path, status, visibility, theme, weight FROM {sections_data} WHERE status=1 ORDER BY weight"); + $res = db_query("SELECT name, path, status, visibility, theme, weight FROM {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 @@ -349,3 +349,49 @@ function sections_in_section($section = } return $output; } + + +/** + * 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 sections_insection should + * provide, rather than returning an object with everything but the + * section name. I wrote this function leveraging rather than rewriting + * sections_in_section. + * + * @param + * Optional $section_to_match a string containing the section name + * you want to test against + * + * @return + * 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 + */ +function sections_check_section($section_to_match = NULL){ + + //get section object + $section_row = 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; +}