Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 04, 2016, 10:19:47 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Looing for Joomla Categories list module  (Read 1494 times)

fenixproductions

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,184
    • View Profile
    • Donate to Member
Looing for Joomla Categories list module
« on: April 01, 2010, 04:16:21 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:
<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.
« Last Edit: April 01, 2010, 04:21:14 AM by fenixproductions »

fenixproductions

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,184
    • View Profile
    • Donate to Member
Re: Looing for Joomla Categories list module
« Reply #1 on: April 01, 2010, 05:22:15 PM »
I will answer myself :)

Code: PHP [Select]
  1. <?php
  2.  
  3. function getSection($iId)
  4. {
  5.         $database = &JFactory::getDBO();
  6.         if(JRequest::getVar( 'view', 0) == "section")
  7.         {
  8.                 return JRequest::getVar( 'id', 0);
  9.         }
  10.         else if(Jrequest::getVar( 'view', 0) == "category")
  11.         {
  12.                 $sql = "SELECT section FROM #__categories WHERE id = $iId ";
  13.                 $database->setQuery( $sql );
  14.                 $row=$database->loadResult();
  15.                 return $row;
  16.         }
  17.         else if(Jrequest::getVar('view', 0) == "article")
  18.         {
  19.                 $temp=explode(":",JRequest::getVar('id',0));
  20.                 $sql = "SELECT sectionid FROM #__content WHERE id = ".$temp[0];
  21.                 $database->setQuery( $sql );
  22.                 $row=$database->loadResult();
  23.                 return $row;
  24.         }
  25. }
  26.  
  27. $section_id=getSection(JRequest::getVar('id',0));
  28.  
  29. ?>
  30.  
  31. <?php
  32.  
  33. function getSectionCategories($iId)
  34. {
  35.         if ($iId == NULL)
  36.         {
  37.                 return NULL;
  38.         }
  39.        
  40.         $database = &JFactory::getDBO();
  41.         $sql = 'SELECT id, title FROM #__categories WHERE section = ' .$iId;
  42.         $database->setQuery( $sql );
  43.         $row=$database->loadRowList();
  44.         return $row;
  45. }
  46.  
  47. ?>
  48.  
  49. <?php
  50.  
  51. function getCategoryArticles($iId)
  52. {
  53.         if ($iId == NULL)
  54.         {
  55.                 return NULL;
  56.         }
  57.        
  58.         $database = &JFactory::getDBO();
  59.         $sql = 'SELECT id, title FROM #__content WHERE catid = ' .$iId;
  60.         $database->setQuery( $sql );
  61.         $row=$database->loadRowList();
  62.         return $row;
  63. }
  64.  
  65. ?>
  66.  
  67. <?php
  68. $categories_array = getSectionCategories($section_id);
  69.  
  70. echo '<div id="menubox-right">';
  71. echo '<div id="menubox-right-top"><span class="header">&nbsp;</span></div>';
  72. echo '<div id="menubox-right-middle">';
  73. echo '<ul class="menubox-right-categories">';
  74.  
  75. for ($i=0; $i < sizeof($categories_array); $i++)
  76. {
  77.         if((Jrequest::getVar('view', 0) == "category") && (JRequest::getVar('id',0) == $categories_array[$i][0]))
  78.         {
  79.                 echo '<li><a href="' .$categories_array[$i][0] .'" class="right-category-active">' .$categories_array[$i][1] .'</a></li>';
  80.         }
  81.         else
  82.         {
  83.                 echo '<li><a href="' .$categories_array[$i][0] .'" class="right-category">' .$categories_array[$i][1] .'</a></li>';
  84.         }
  85.        
  86.         $articles_array = getCategoryArticles($categories_array[$i][0]);
  87.        
  88.         if (sizeof($articles_array) > 0)
  89.         {
  90.                 echo '<ul class="menubox-right-articles">';
  91.                 for ($j=0; $j < sizeof($articles_array); $j++)
  92.                 {
  93.                         if((Jrequest::getVar('view', 0) == "article") && (JRequest::getVar('id',0) == $articles_array[$j][0]))
  94.                         {
  95.                                 echo '<li>!<a href="' .$articles_array[$j][0] .'" class="right-article-active">' .$articles_array[$j][1] .'</a></li>';
  96.                         }
  97.                         else
  98.                         {
  99.                                 echo '<li><a href="' .$articles_array[$j][0] .'" class="right-article">' .$articles_array[$j][1] .'</a></li>';
  100.                         }
  101.                 }
  102.                 echo '</ul>';
  103.         }
  104. }
  105.  
  106. echo '</ul>';
  107. echo '</div>';
  108. echo '<div id="menubox-right-bottom">&nbsp;</div>';
  109. echo '</div>';
  110.  
  111. ?>

Of course, it's not all but now it is pretty easy to finish.