Created
July 30, 2014 15:27
-
-
Save betweenbrain/a6ed70c49f98852aae48 to your computer and use it in GitHub Desktop.
Sort Joomla items by parent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query | |
->select($this->db->quoteName(array( | |
'title', | |
'id', | |
'parent_id'))) | |
->select($this->db->quoteName('metadesc', 'description')) | |
->from($this->db->quoteName('#__categories')) | |
->order($this->db->quoteName('parent_id') . ' ASC') | |
->order($this->db->quoteName('ordering') . ' ASC'); | |
$children = array(); | |
if ($items) | |
{ | |
foreach ($items as $item) | |
{ | |
$list = @$children[$item->parent] ? $children[$item->parent] : array(); | |
array_push($list, $item); | |
$children[$item->parent] = $list; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment