/ Published in: PHP
function for determining the section ID of a given page. Good to include in a templatetools.php file inside of a template to set up some custom conditional logic
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getSection($iId) { /** function for determining the section ID of a given page, referenced from: * http://forum.joomla.org/viewtopic.php?f=466&t=302292 */ $database = &JFactory::getDBO(); if(JRequest::getVar( 'view', 0) == "section"){ return JRequest::getVar( 'id', 0); }else if(Jrequest::getVar( 'view', 0) == "category"){ $sql = "SELECT section FROM #__categories WHERE id = '$iId'"; $database->setQuery( $sql ); $row=$database->loadResult(); return $row; }else if(Jrequest::getVar('view', 0) == "article"){ $sql = "SELECT sectionid FROM #__content WHERE id = ".$temp[0]; $database->setQuery( $sql ); $row=$database->loadResult(); return $row; } } $section_id=getSection(JRequest::getVar('id',0)); if (JRequest::getVar('option') == 'com_glossary') { $section_id = '10'; }
URL: http://forum.joomla.org/viewtopic.php?f=466&t=302292