Keyword

HELP! setQuery get items from all subcategories?

  • Boris Sehovac
  • Boris Sehovac's Avatar Topic Author
  • Offline
  • New Member
More
12 years 8 months ago #61120 by Boris Sehovac
I have a plugin that lists only items from ONE LEVEL of subcategories. Here is PHP code:

do{
$db->setQuery("SELECT id FROM #__k2_categories WHERE parent IN(".implode(",",$level).")");
$level = (array)$db->loadResultArray();
//if(is_array($level) && count($level) > 0){
$catid = array_merge((array)$catid,(array)$level);
//}
//else break;
}while($db->getNumRows() > 0);

And here is examle of what items do it lists, i have this categories:

Category1
--Subcategory 1 (Item1, Item2)
----Subcategory 1a (Item1a)
----Subcategory 1b (item1b)
--Subcategory2 (Item3)

And when I open Category1, it onli lists Item1, Item2 and Item3. Can someone please help me to get Item1a and Item1b...

Sorry for bad english, and thank you!

Please Log in or Create an account to join the conversation.

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
12 years 8 months ago #61121 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: HELP! setQuery get items from all subcategories?
Hello, Boris.

I am not complitely undertood your example, but you can use a getCategoryTree function from itemlist model for this purpose.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum