Skip to content

Instantly share code, notes, and snippets.

@simenbrekken
Created September 4, 2012 10:50
Show Gist options
  • Select an option

  • Save simenbrekken/3620046 to your computer and use it in GitHub Desktop.

Select an option

Save simenbrekken/3620046 to your computer and use it in GitHub Desktop.
Vae property plucker.
<?
function vae_pluck($path, $properties, $json = true) {
$results = array();
$context = vae($path);
foreach ($context as $entry) {
$result = array();
foreach ($properties as $key) {
$property = $entry[$key];
switch ($property->structure->type) {
case 'FileItem':
$value = vae_data_url() . vae_file($property);
break;
case 'ImageItem':
$value = vae_data_url() . vae_image($property);
break;
default:
$value = (string) $property;
if (is_float($value)) {
$value = (float) $value;
} else if (is_int($value)) {
$value = (int) $value;
}
}
$result[$key] = $value;
}
$results[] = $result;
}
return $json ? json_encode($results) : $results;
}
print_r(vae_pluck('/settings/backgrounds[section="home"]', array('section', 'image')));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment