joomla - where is category ordering stored?
Asked Answered
D

1

6

I have a question that might seem simple, but yet I was unable to find the answer. Unlike articles, which are stored in table jos_content, categories in table jos_categories lack any column named ordering or any other that would have the desired information stored. I also tried to find anything similar in the jos_assets table, but it did not help either.

I am hacking the content component a little and I need to get my child categories ordered by the ordering when calling $parent->getChildren() or just find the ordering column so I can create my own query even though it's not clean, I just need to get it working ASAP.

So where can I find category ordering or how do I force getChildren method to return ordered results?

Thanks in advance, Elwhis

Doug answered 28/8, 2011 at 16:48 Comment(0)
N
8

In Joomla categorises' order is stored in table "jos_categories" as hierarchical tree structure with a set of linked nodes. Columns used to set order are: "parent_id", "lft", "rgt" and "level".

Assets and menu items are stored in the same way.

You can read more about "Tree traversal" on wiki

Edit: From Joomla 1.6 to load a specific category and all its children in a JCategoryNode object use:

jimport( 'joomla.application.categories' );

$extension = 'Content'; // com_content
$options['countItems'] = true;
$categoryId = 0;

$categories = JCategories::getInstance($extension, $options);
$categories->get($categoryId);
Nur answered 28/8, 2011 at 19:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.