Skip to content

Instantly share code, notes, and snippets.

@betweenbrain
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betweenbrain/e07c94110d5b843ad0bc to your computer and use it in GitHub Desktop.
Save betweenbrain/e07c94110d5b843ad0bc to your computer and use it in GitHub Desktop.
Force group / sort Joomla items by category
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')))
->from($db->quoteName('#__categories'))
->where($db->quoteName('published') . ' = ' . $db->quote('1') .
' AND ' . $db->quoteName('extension') . ' = ' . $db->quote('com_content'))
->order('LFT ASC');
$db->setQuery($query);
$categories = $db->loadObjectList('id');
foreach ($categories as $category)
{
foreach ($this->intro_items as $key => $intro_item)
{
if ($intro_item->catid == $category->id)
{
$this->intro_items[] = $intro_item;
unset ($this->intro_items[$key]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment