1
  1. In Zoo Applications I create element Radio with 3 options: Red, Green, Blue
  2. I need acess this "option value" was stored: red or green or blue in database like this:

    "7045c737-906a-4776-b390-0f9529b411a6": { "option": { "0": "red" } },

How can i load this value "red"? I try this:

$zoo= App::getInstance('zoo');
$Zoo_Item_id= $item_id;
$items = $zoo->table->item->get($Zoo_Item_id);
$element_id = 'e455c93e-6514-480b-8891-e61a9ef32a99';
$element_value = $items->getElement($element_id)->getElementData()->get('value');

But for "radio" not working; If i change $element_id for text content this code working fine.

I see documentation for element access: http://yootheme.com/zoo/documentation/developers/accessing-element-data But when element was radio, i dont know what do.

Can you help me please?

1

I solve how to acces data from elements ZOO. In files:

/media/zoo/applications/YOUR_APP/templates/YOUR_TEMPLATE/renderer/item/teaser.php

you can add this code:

$element1 = $item->getElement('ff944545-de96-45ed-ae24-9126ab82ca7b'); 
foreach ($element1 as $self) {
    $file1 = $self['file'];
}

Important: "ff944545-de96-45ed-ae24-9126ab82ca7b" is your unique element ID; "['file']" is the filed in data array;

UPDATED in: 2016-10-04: I found another easy way if your data was in Array:

In teaser.php or full.php you can access any information on element with code like this:

<?php  
$status = $item->getElement('0e3527e4-032c-4d35-a630-7b0418eb9ecc')->getElementData()->get('option');  
print_r($status['0'];   
?>

In some cases, 'option' need be replced by 'value'. You need access your data base and see the structure of element like this:

"0e3527e4-032c-4d35-a630-7b0418eb9ecc":  {
        "option":  {
            "0": "em-andamento"
        },
        "select": "1"
    },

See this other obeject structure ofr 'value' case:

"d9f72e0a-50d3-4be7-89f4-4d30b11aa5a1":  {
        "0":  {
            "value": "2015-11-18 02:00:00"
        }
    },

I hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.