I'm creating a Joomla 3x SP Pagebuilder3 addon, but I'm having a bit of challenge getting a database results as an option in a select type.
This is what I've done so far.
class MyCustomTypes {
public static function getBannerCats(){
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select(array('id', 'title', 'alias'))
->from('#__categories')
->where('extension = ' . $db->quote('com_banners'))
->where('parent_id > 0')
->where('published > -1');
$db->setQuery($query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
// THIS IS WHERE MY PROBLEM IS
$options[] = $item->title;
}
}
// $options = array_merge(parent::getOptions(), $options);
return $options;
}
}
I want to options to show here
'category_ids'=>array(
'type'=>'select',
'title'=>JText::_('Categories'),
'desc'=>JText::_('Category Source'),
'values'=>array(MyCustomTypes::getBannerCats()),// Result will show here like so 'result_id'=>'result_title'
)
I will be glad if someone can help me. Thank you.
$options
contain? – mickmackusa♦ Nov 23 '18 at 3:08