<?php
function getSection($iId)
{
$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")
{
$temp=explode(":",JRequest
::getVar('id',0)); $sql = "SELECT sectionid FROM #__content WHERE id = ".$temp[0];
$database->setQuery( $sql );
$row=$database->loadResult();
return $row;
}
}
$section_id=getSection(JRequest::getVar('id',0));
?>
<?php
function getSectionCategories($iId)
{
if ($iId == NULL)
{
return NULL;
}
$database = &JFactory::getDBO();
$sql = 'SELECT id, title FROM #__categories WHERE section = ' .$iId;
$database->setQuery( $sql );
$row=$database->loadRowList();
return $row;
}
?>
<?php
function getCategoryArticles($iId)
{
if ($iId == NULL)
{
return NULL;
}
$database = &JFactory::getDBO();
$sql = 'SELECT id, title FROM #__content WHERE catid = ' .$iId;
$database->setQuery( $sql );
$row=$database->loadRowList();
return $row;
}
?>
<?php
$categories_array = getSectionCategories($section_id);
echo '<div id="menubox-right">';
echo '<div id="menubox-right-top"><span class="header"> </span></div>';
echo '<div id="menubox-right-middle">';
echo '<ul class="menubox-right-categories">';
for ($i=0; $i < sizeof($categories_array); $i++) {
if((Jrequest::getVar('view', 0) == "category") && (JRequest::getVar('id',0) == $categories_array[$i][0]))
{
echo '<li><a href="' .$categories_array[$i][0] .'" class="right-category-active">' .$categories_array[$i][1] .'</a></li>';
}
else
{
echo '<li><a href="' .$categories_array[$i][0] .'" class="right-category">' .$categories_array[$i][1] .'</a></li>';
}
$articles_array = getCategoryArticles($categories_array[$i][0]);
if (sizeof($articles_array) > 0) {
echo '<ul class="menubox-right-articles">';
for ($j=0; $j < sizeof($articles_array); $j++) {
if((Jrequest::getVar('view', 0) == "article") && (JRequest::getVar('id',0) == $articles_array[$j][0]))
{
echo '<li>!<a href="' .$articles_array[$j][0] .'" class="right-article-active">' .$articles_array[$j][1] .'</a></li>';
}
else
{
echo '<li><a href="' .$articles_array[$j][0] .'" class="right-article">' .$articles_array[$j][1] .'</a></li>';
}
}
echo '</ul>';
}
}
echo '</ul>';
echo '</div>';
echo '<div id="menubox-right-bottom"> </div>';
echo '</div>';
?>