首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pimcore 5:以编程方式将Brick添加到Areablock (文档自动化)

Pimcore 5:以编程方式将Brick添加到Areablock (文档自动化)
EN

Stack Overflow用户
提问于 2018-03-22 05:42:06
回答 1查看 420关注 0票数 0

我正在尝试将Pimcore 4实例中相当复杂的页面迁移到更新后的Pimcore实例中(本文发表时为5个)。

我已经设法将objectsasset赋值转换为这些对象的fields,但是我还没有找到一种方法来自动将bricks包含和配置为document中的Areablock可编辑内容类型。

根据Pimcore 5文档,文档创建通过以下方式完成:

代码语言:javascript
复制
<?php

  // Create a new document, name it, and assign a parent...
  $page = new \Pimcore\Model\Document\Page();
  $page->setKey( 'my-new-document' );
  $page->setParentId( 82 );

  // This is where you'd automate the brick configuration...

  // All done, save the document...
  $page->save();

如果任何人在这方面有任何成功的经验,我将非常感谢所提供的任何帮助。

EN

回答 1

Stack Overflow用户

发布于 2018-03-26 00:26:03

我建议查看getElements()的输出,根据需要进行修改,并将其提供给setElements()

代码语言:javascript
复制
    $page = \Pimcore\Model\Document::getById($page_of_interest);
    $elements = $page->getElements();
    // Update $elements (namely changing documentId to the id of the new page, and updating field names/types)
    $new_page = new \Pimcore\Model\Document\Page();
    $new_page->setKey('my-new-page');
    $new_page->setElements($elements);
    $new_page->save();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49416991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档