| Subcategories |
| Sunday, 07 June 2009 14:24 |
|
I was working on one of my components that needed to have subcategories. Since Joomla (1.5.x) doesn't support it I've came up with this simple code to achieve it:
In you component category table you will have somethin like:
ID (The ID of the category or subcategory) Name (The name of the category) Sub (The ID of the parent category) Published (If it's published or not)
Then in your code you can use this piece of code to get a category/subcategory dropdown:
$query = "SELECT id AS value, name as text FROM #__mycomponent_categories WHERE published = '1' and sub='0' ORDER BY name";
|













