Created
June 5, 2015 10:12
-
-
Save phproberto/93958513db6d8a08645f to your computer and use it in GitHub Desktop.
Joomla: Get available values for a fieldsattach multiple selector
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 | |
$db = JFactory::getDbo(); | |
// Get the available offices | |
$offices = array(); | |
$officeFieldId = 5; | |
$query = $db->getQuery(true) | |
->select('field.extras') | |
->from('#__fieldsattach AS field') | |
->where('field.id = ' . (int) $officeFieldId); | |
$db->setQuery($query); | |
$officesData = $db->loadResult(); | |
if ($officesData) | |
{ | |
$officesData = explode(chr(13), $officesData); | |
foreach ($officesData as $officeData) | |
{ | |
$officeData = explode('|', $officeData); | |
if (count($officeData) != 2) | |
{ | |
continue; | |
} | |
$offices[] = (object) array( | |
'alias' => trim($officeData[1]), | |
'name' => trim($officeData[0]) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment