Last active
August 31, 2017 20:15
-
-
Save exa18/af204877968c789e247ff7c37b6c39f1 to your computer and use it in GitHub Desktop.
Concrete5 get attribute select in block or controller
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 | |
function __construct($obj = null) | |
{ | |
parent::__construct($obj); | |
$db = Loader::db(); | |
// attribute to get like selection field | |
$n='nav_item_class'; | |
// Get SelectOptionID as SOL | |
$q="SELECT ss.avSelectOptionListID as sol FROM AttributeKeys AS ak LEFT JOIN atSelectSettings AS ss ON ss.akID=ak.akID LEFT JOIN AttributeTypes AS at ON at.atID=ak.atID WHERE ak.akHandle LIKE '{$n}' AND ak.akCategory='pagekey' AND at.atHandle='select'"; | |
$e = $db->getAll($q); | |
$sol=$e[0]['sol']; | |
if ($sol) { | |
// Get values in order in displayOrder and not isDeleted=1 | |
$q="SELECT value FROM atSelectOptions WHERE isDeleted=0 AND avSelectOptionListID='{$sol}' ORDER BY displayOrder ASC"; | |
$e = $db->getAll($q); | |
// Extract values | |
foreach($e as $ak) { | |
$i=$ak['value']; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment