DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Looing for Joomla Categories list module  (Read 4,389 times)

fenixproductions

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,186
    • Participated in NANY Challenge Four Times
Looing for Joomla Categories list module
« on: April 01, 2010, 09:16 AM »
Hi all, long time no see

I am making a web page based on Joomla for a friend and I wonder did anyone found a free extension which could solve my problem:

I need to have Categories list with all articles assigned to them from current section only. I was trying dozen of existing modules and none of them have the simplicity I need. After few hours of trying to make them work my way I have enough, but promised deadline is coming. I believe it shouldn't be hard to code but, recently, I don't have enough nerves for that :(

The only thing I'd like to see is something like this generated:
Code
<ul clas="xxx">
<li>Category name</li>
<li>
     <ul>
           <li id="art-$id"><a href="">Article name</a></li>
           <li id="art-$id"><a href="">Article name</a></li>
     </ul>
</li>
<li>Second Category name</li>
<li>
     <ul>
           <li id="art-$id"><a href="">Article name</a></li>
     </ul>
</li>
</ul>

Will someone give a little help for forgotten member? I would really appreciate any effort.

Thank you in advance.

P.S. If such module could work with JoomFish without glitches it would be pretty awesome.
Надо было учиться, а не камни в школу бросать...
--
f0dder is my personal hero :)
« Last Edit: April 01, 2010, 09:21 AM by fenixproductions »

fenixproductions

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,186
    • Participated in NANY Challenge Four Times
Re: Looing for Joomla Categories list module
« Reply #1 on: April 01, 2010, 10:22 PM »
I will answer myself :)

Code: (php)
<?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">&nbsp;</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">&nbsp;</div>';
echo '</div>';

?>

Of course, it's not all but now it is pretty easy to finish.
Надо было учиться, а не камни в школу бросать...
--
f0dder is my personal hero :)

Original address: https://www.donationcoder.com/forum/index.php?topic=22297.0