Posted By

bubaphex on 10/27/11


Tagged

joomla


Versions (?)

Get Section ID


 / Published in: PHP
 

  1. //Getting Section ID
  2. function getSection($iId) {
  3. $database = &JFactory::getDBO();
  4.  
  5. $sql = "SELECT s.id ";
  6. $sql .= "FROM #__sections as s join #__content as c on c.sectionid = s.id ";
  7. $sql .= "WHERE c.id = $iId ";
  8. $database->setQuery( $sql );
  9. $row=$database->loadResult();
  10. return $row;
  11. }
  12. $section=getSection(JRequest::getInt( 'id'));
  13.  
  14. //Find the id
  15. echo $section;
  16.  
  17. // If statement
  18. if ($section == 1) {
  19. echo 'Section with Id of 1';
  20. } else {
  21. echo 'This section isnt section 1';
  22. }

Report this snippet  

You need to login to post a comment.