Quantcast
Channel: Lecciones Prácticas » Joomla
Viewing all articles
Browse latest Browse all 8

Joomla: know the section [SOLVED]

$
0
0

Lets suppose you are developing a joomla module and want to know the section in which you are.

The following code might help :)

<?php
function getSection($iId) {
    $database = &JFactory::getDBO();
    if(Jrequest::getCmd('view',0) == "section") {
        return JRequest::getInt('id');
    }
    elseif(Jrequest::getCmd('view',0) == "category") {
        $sql = "SELECT section FROM #__categories WHERE id = $iId ";
        $database->setQuery( $sql );
        $row=$database->loadResult();
        return $row;
    }
    elseif(Jrequest::getCmd('view',0) == "article") {
        $temp=explode(":",JRequest::getInt('id'));
        $sql = "SELECT sectionid FROM #__content WHERE id = ".$temp[0];
        $database->setQuery( $sql );
        $row=$database->loadResult();
        return $row;
    }
}
 
// use it like:
$sectionId=getSection(JRequest::getInt('id'));
?>

Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images