【问题标题】:How get object from indices in Areablock?如何从 Areablock 中的索引中获取对象?
【发布时间】:2016-07-27 22:51:08
【问题描述】:

我有带有索引树元素表的 Pimcore\Model\Document\Tag\Areablock:

array(3) {
    [0]=>
    array(2) {
      ["key"]=>
      string(1) "3"
      ["type"]=>
      string(8) "newsData"
    }
    [1]=>
    array(2) {
      ["key"]=>
      string(1) "1"
      ["type"]=>
      string(7) "wysiwyg"
    }
    [2]=>
    array(2) {
      ["key"]=>
      string(1) "2"
      ["type"]=>
      string(12) "videogallery"
    }
}

如何从 Areablock 对象中获取 newsData 对象?

我在 Areablock 中找不到相关功能,也不知道如何获取日期。

提前致谢。

【问题讨论】:

    标签: pimcore


    【解决方案1】:

    Areabricks 不是实际 areablock 的子元素,而是当前文档的直接元素。他们的名字只是构造不同。

    $areablock = $this->areablock("yourAreablock");
    
    foreach ($areablock->getData() as $brick) {
        if ($brick["type"] == "yourAreaBrickName") {
            $nameOfTheEditableInBrick = "bigtitle";
            $indexOfTheAreaBrick = $brick["key"];
            // This is your element
            $subelement = $this->document->getElement($nameOfTheEditableInBrick . $areablock->getName() . $brick["key"]);
       }
    }
    

    【讨论】:

    • 对于 Pimcore 5 站点:$this->document->getElement( $block_name.':'.$brick[ 'key' ].'.'.$editable_name);
    猜你喜欢
    • 1970-01-01
    • 2021-09-25
    • 1970-01-01
    • 2020-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-15
    相关资源
    最近更新 更多