Accessing brick data programmatically

Hey all,

I am trying to make the following scenario work: Given a Page (Document\Page), find all the elements of type “section” in the content, and extract the titles of those that are not hidden. This is to build up a content navigation.
I am successfully extracting the titles with this code (this is in a Twig extension):

        $sectionTitles = [];
        /** @var Document\Tag\Areablock $content */
        $content = $page->getElement('content');
        foreach ($content->getElement('section') as $section) {
            $title = $section->getElement('sectionTitle') ? $section->getElement('sectionTitle')->getData() : '';
            if ($title && strlen($title) > 0) {
                $sectionTitles[] = $title;

        return $sectionTitles;

However, I cannot seem to figure out how to get any metadata (such as, is this brick currently hidden) or really any structured data out of the element (an object of class Pimcore\Model\Document\Tag\Areablock\Item) I have here. What I actually need is an Areablock element (such as the one I get from the first getElement() call, but I can’t get it from the Item object. Can anyone help me out here?


The brick itself doesn’t have any property like hidden or published.
Instead, the brick element can be identified by “published” status.
eg. if brick element is a type page, then we check if the page is published or not. and further use it as a flag in navigation.

Let me know if that answers your query.