kaliop-uk / ezmigrationbundle

This bundle makes it easy to handle eZPlatform / eZPublish5 content upgrades/migrations
GNU General Public License v2.0
53 stars 81 forks source link

Use references in locationlist for pagebuilder block item #192

Open raupie opened 5 years ago

raupie commented 5 years ago

I have a landing_page/page_builder content item with multiple zones and blocks. In my migration I am creating other content items and using references to store the content_id.

So for injecting id's into a block that is a collection it uses name: locationlist, value: '1,2,3'

What I was hoping to do was 'name: locationlist, value: 'reference:page_1,reference:page_2,reference:page_3'

gggeek commented 5 years ago

did you try with:

value: '[reference:page_1],[reference:page_2],[reference:page_3]'
raupie commented 5 years ago

name: locationlist, value: '[reference:ref.articles.article_1],[reference:ref.articles.article_2],[reference:ref.articles.article_3]'

Migration aborted! Reason: Error in execution of step 35: Cache key "ez-location-[reference:ref.articles.article_1]-1" contains reserved characters {}()/\@: in file /var/www/html/project/ezplatform/vendor/symfony/symfony/src/Symfony/Component/Cache/CacheItem.php line 162

raupie commented 5 years ago

Looks like it doesn't like the colon between reference:ref

gggeek commented 5 years ago

I would think that the reference has not been resolved, if it gets used as cache-key by the kernel. a) is the name of the reference that you set really 'ref.articles.article_1' ? if so, could you replace it with fe. 'ref-articles-article_1' ? b) would you be able to post a slightly bigger yml snippet for me to play around with?

raupie commented 5 years ago

I will change my reference tagging format. Is there a reason why - vs . to separate hierarchy?

# Shared "dummy" content for development

# create dummy authors
-
    type: user
    mode: create
    first_name: Stephen
    last_name: King
    username: stephen.king
    email: stephen.king@author.com
    password: password123
    lang: eng-GB
    groups: [authors_group]
    references:
        -
            identifier: ref-user-stephen_king
            attribute: user_id

-
    type: content
    mode: update
    lang: eng-GB
    match:
        content_id: "reference:ref-user-stephen_king"
    new_remote_id: user.stephen_king
    attributes:
        job_title: 'Famous Author'

# create dummy "articles" folder
-
    type: content
    mode: create
    content_type: folder
    parent_location: 2
    priority: 0
    is_hidden: false
    sort_field: name
    sort_order: ASC
    section: 1
    owner: 14
    lang: eng-US
    always_available: false
    remote_id: articles
    location_remote_id: articles
    attributes:
        name: 'Articles'
    references:
        -
            identifier: ref-articles
            attribute: content_id

# create dummy "article" objects
-
    type: content
    mode: create
    content_type: article
    parent_location: articles
    owner: 14
    lang: eng-US
    remote_id: articles.article_1
    location_remote_id: articles.article_1
    attributes:
        name: Article 1 Title
        short_name: Article 1 Short Title
        date: 09/01/2018
        author: ["reference:ref-user-stephen_king"]
        intro: |
            Article 1 intro blurb text for testing the output on certain templates. This is another example sentence for testing.
        body: |
            <?xml version="1.0" encoding="UTF-8"?>
            <section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
                <h2>Article 1 Body</h2>
                <p class="paraClass">Article 1 Body Text</p>
            </section>
    references:
        -
            identifier: ref-articles-article_1
            attribute: content_id

-
    type: content
    mode: create
    content_type: article
    parent_location: articles
    owner: 14
    lang: eng-US
    remote_id: articles.article_2
    location_remote_id: articles.article_2
    attributes:
        name: Article 2 Title
        short_name: Article 2 Short Title
        date: 10/02/2018
        author: ["reference:ref-user-stephen_king"]
        intro: |
            Article 2 intro blurb text for testing the output on certain templates. This is another example sentence for testing.
        body: |
            <?xml version="1.0" encoding="UTF-8"?>
            <section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
                <h2>Article 2 Body</h2>
                <p class="paraClass">Article 2 Body Text</p>
            </section>
    references:
        -
            identifier: ref-articles-article_2
            attribute: content_id

-
    type: content
    mode: create
    content_type: article
    parent_location: articles
    owner: 14
    lang: eng-US
    remote_id: articles.article_3
    location_remote_id: articles.article_3
    attributes:
        name: Article 3 Title
        short_name: Article 3 Short Title
        date: 11/03/2018
        author: ["reference:ref-user-stephen_king"]
        intro: |
            Article 3 intro blurb text for testing the output on certain templates. This is another example sentence for testing.
        body: |
            <?xml version="1.0" encoding="UTF-8"?>
            <section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
                <h2>Article 3 Body</h2>
                <p class="paraClass">Article 3 Body Text</p>
            </section>
    references:
        -
            identifier: ref-articles-article_3
            attribute: content_id

# create dummy "landing page" object
-
    type: content
    mode: create
    content_type: landing_page
    parent_location: 2
    owner: 14
    lang: eng-US
    remote_id: landingpage.landing_page_test
    attributes:
        name: Landing Page Test
        description: Landing Page Description
        page:
            layout: sidebar_right
            zones:
                - { id: '2', name: 'First zone', blocks: [{ visible: true, id: '1', type: collection, name: 'Recommended Articles', view: featured, class: null, style: null, compiled: '', since: null, till: null, attributes: [{ id: '2', name: block_displayName, value: '1' }, { id: '3', name: block_description, value: 'Recommended Articles Description text' }, { id: '4', name: locationlist, value: '[reference:articles-article_1],[reference:articles-article_2],[reference:articles-article_3'}] }] }

                - { id: '3', name: 'Second zone', blocks: [{ visible: true, id: '2', type: collection, name: 'Related Articles', view: sidebar, class: null, style: null, compiled: '', since: null, till: null, attributes: [{ id: '11', name: block_displayName, value: '1' }, { id: '12', name: block_description, value: 'Related Articles Description text' }, { id: '13', name: locationlist, value: '[reference:articles-article_1],[reference:articles-article_2],[reference:articles-article_3'}] }] }
    references:
        -
            identifier: ref-landing_page_test
            attribute: content_id

# NOTE: Keep this block at the bottom of this file
# create relationships between articles and products
-
    type: content
    mode: update
    lang: eng-US
    match:
        content_remote_id: articles.article_1
    attributes:
        related_articles: [ articles.article_2, articles.article_3 ]

-
    type: content
    mode: update
    lang: eng-US
    match:
        content_remote_id: articles.article_2
    attributes:
        related_articles: [ articles.article_3 ]
gggeek commented 5 years ago

I will change my reference tagging format. Is there a reason why - vs . to separate hierarchy?

No, I just thought that the dot was the offending character. Re-reading your comment, it seems that it was the colon instead...

raupie commented 5 years ago

Looks like the same thing is happening when I switch the tags to use references instead of hard coding the keyword.

Migration aborted! Reason: Error in execution of step 21: Cache key "netgen-tag-reference:tag-industries-environmental-0-1" contains reserved characters {}()/\@: in file /var/www/html/project/ezplatform/vendor/symfony/symfony/src/Symfony/Component/Cache/CacheItem.php line 162
-
  type: tag
  mode: create
  lang: eng-US
  parent_tag_id: "reference:tag-product_1"
  keywords: Product 1
  references:
    -
      identifier: tag-product_1
      attribute: id
-
  type: tag
  mode: create
  lang: eng-US
  parent_tag_id: "reference:tag-product_2"
  keywords: Product 2
  references:
    -
      identifier: tag-product_1
      attribute: id

-
  type: content
  mode: create
  content_type: article
  parent_location: "reference:articles"
  owner: 14
  lang: eng-US
  attributes:
    name: Article 1 Title
    short_name: Article 1 Short Title
    date: 09/01/2018
    author: ["reference:user-stephen_king", "reference:user-jrrtolkien"]
    intro: |
      Article 1 intro blurb text for testing the output on certain templates. This is another example sentence for testing.
    body: |
      <?xml version="1.0" encoding="UTF-8"?>
      <section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
          <h2>Article 1 Body</h2>
          <p class="paraClass">Article 1 Body Text</p>
      </section>
    related_searches: Related Search 1, Related Search 2, Related Search 3
    tags:
      - id: ["reference:tag-industries-environmental", "reference:tag-products-columns"]
  references:
    -
      identifier: articles-article_1
      attribute: content_id