简体   繁体   中英

joomla - where is category ordering stored?

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM