I am trying to create a more robust Related Items section that will display in the item.php file. It is intended to be a new section and not change the default Related Items. I would like to display all items in the category, except the one being viewed.
My thoughts were I could do a table lookup using the current 'item id' to get the 'catid' value from the '#__k2_items" table.
// GET ID
$itemID = JRequest::getInt('id');
// Lookup Cat ID for Current Item
$db =& JFactory::getDBO();
$db->setQuery('SELECT catid FROM #__k2_items WHERE id="'.$itemID.'"');
// Load Category ID for Current Item
$itemCatID = $db->loadResult();
// Verify Category Id is being obtained - REMOVE AFTER
echo 'Category ID = '.$itemCatID.'<br/>';
So far so good, the correct 'catid' value is being displayed.
I would then query the same table to get all the 'item id' values that have the same 'catid' value (belong to same category). The problem I have is I an not familiar with how to make this query using Joomla coding practices.
I was hoping someone might be able to help understand how to write this query using Joomla coding practices. Any advice would be appreciated.
Once I can get the list of item id's I am quite comfortable with the rest.