Access Element Data

This short tutorial will show you how to access element data from anywhere in ZOO.


Getting Started

In general, you can get an element from an item like this:

$element = $item->getElement('ELEMENT_ID');

Now, if you don't have the item, but the item id. Do this:

$item = $this->app->table->item->get('ITEM_ID');

Now if you don't have the element id. You can always iterate over all item elements by calling:

foreach ($item->getElements() as $element) {
    do_something_with_the_element($element);
}

With the Element object, you can get and set values through its getter and setter functions.

public function get($name, $default = null);
public function set($name, $value);

If it is a repeatable element, iterate over the element itself:

foreach ($element as $self) {
    $data = $self['value'];
}

This should save some time looking through the code!

ZOO Documentation