Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Entities and assets don't get linked when using multiple locales #95

Closed
frankmarineau opened this issue Sep 22, 2016 · 22 comments
Closed
Assignees
Labels

Comments

@frankmarineau
Copy link

frankmarineau commented Sep 22, 2016

If I add locales: '*' to the CDA query, assets and links will only show the sys key and won't be populated with the actual linked resource. In the following example, I'm using two locales (en-us and fr-CA) and two content types: a Section that contains multiple _Topic_s

Here's the generated yml I get for a Section if I don't specify multiple locales in the CDA query (f.cda_query = {}):

---
:id: 1RU28gignOCGg0UMau0mcM
:title: Life
:topics:
- :id: 5Hf7MhcNaw4OWoAWKYWa6M
  :question: Why?
  :answer: Because

💯 . The associated _Topic_s are populated.

Here is what I get when I set f.cda_query = { locales: '*' }:

---
:id: 1RU28gignOCGg0UMau0mcM
:title:
  :en-US: Life
  :fr-CA: La vie
:topics:
  :en-US:
  - sys:
      type: Link
      linkType: Entry
      id: 5Hf7MhcNaw4OWoAWKYWa6M

It loads plain fields just fine (the title), but linked entries are no longer populated.

For reference, here's what one of the Topic yml files looks like:

---
:id: 1RU28gignOCGg0UMau0mcM
:title:
  :en-US: Life
  :fr-CA: La vie
:topics:
- :id: 5Hf7MhcNaw4OWoAWKYWa6M
  :en-US:
    :question: Why?
    :answer: Because
  :fr-CA:
    :question: Pourquoi?
    :answer: Parce que

It's not shown in the above example, but the same issue happens with linked assets.

Additional information

  • Ruby 2.2.3
  • Middleman 3.4.1
  • Latest published contentful_middleman (also tried with both contentful.rb and this repo's master)
  • Tried with these two content type settings:
    • i18n enabled on the Section "topics" one-to-many reference field and i18n disabled on the Topic fields (question and answer)
    • i18n disabled on the "topics" reference but enabled on Topic's fields.

Any idea how to solve this? Thanks!

@dlitvakb dlitvakb added the bug label Sep 22, 2016
@dlitvakb dlitvakb self-assigned this Sep 22, 2016
@dlitvakb
Copy link
Contributor

Hey @frankmarineau,

Looks like there is an issue with link resolution for localized content.

I will look into it next week (I'm on vacation until Monday).

In the meantime, you can solve the links locally by filtering in the views.

Cheers

@frankmarineau
Copy link
Author

Thanks a lot @dlitvakb!

@martzoukos
Copy link

Hey there,

I'm also currently facing this issue and try to filter the entries in the views but I'm having some trouble with fetching linked assets.

I have a content_type named block_images and a typical response includes something like that:

:id: 2xsRcbi9tiUcGG84eKYywM
:name:
  :de-DE: List of Images
:images:
  :de-DE:
  - sys:
      type: Link
      linkType: Asset
      id: 3xTPCFNqbSsAyKEUGcOoyy
  - sys:
      type: Link
      linkType: Asset
      id: 5y2zucqvnigog20eMGaIQi
  - sys:
      type: Link
      linkType: Asset
      id: 53yAt8gfOMee6akGUe4m06
  - sys:
      type: Link
      linkType: Asset
      id: 1yUI3W7JqMOUGiCckcqkE0

How can I access the information of these linked Assets? I tried maybe fetching them locally by passing the following:

  f.content_types = {
    ...
    assets: 'Assets'
  }

but that doesn't work.

Any ideas about that?

Thank you very much in advance!

@dlitvakb
Copy link
Contributor

Hey @martzoukos,

Sadly Assets are not regular entries, so they use a different API endpoint.

I will try to get this solved between today and tomorrow, and release a new version with the fix early next week.

Hope that helps

@martzoukos
Copy link

Thank you very much @dlitvakb !

@martzoukos
Copy link

Fantastic. Thank you again David!

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 4, 2016

@martzoukos no problem! new version 1.4.1 has been released as well

Cheers

@martzoukos
Copy link

Hey David,

I'm still getting the same

:images:
  :de-DE:
  - sys:
      type: Link
      linkType: Asset
      id: 3xTPCFNqbSsAyKEUGcOoyy

response.
I changed the version of middleman-contentful in my gemfile to 1.4.1 and ran bundle update. Is there anything else I need to do?

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 4, 2016

Hey @martzoukos, are you using contentful 1.0.1? This fix depends on the update of the contentful gem

@martzoukos
Copy link

@dlitvakb I see that I'm using 1.0.1 in my Gemfile.lock.

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 4, 2016

You can check by running bundle exec ruby -e "require 'contentful'; puts Contentful::VERSION"

@martzoukos
Copy link

Thanks, it outputs 1.0.1 so I'm using the latest version.

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 4, 2016

@martzoukos could you try again running like bundle exec middleman contentful making sure that the versions are 1.4.1 and 1.0.1 for contentful_middleman and contentful respectively.

If the issue still persists, please open a Support ticket and share the details there? I'll be able to look in detail in your case, maybe I missed something on the fix.

Cheers

@martzoukos
Copy link

Tried running bundle exec middleman contentful and the issue still persists. By Support ticket you mean in contentful.com or an issue in this repo?

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 4, 2016

In app.contentful.com, please request to be assigned to me.

@martzoukos
Copy link

Will do. Thanks!

@frankmarineau
Copy link
Author

@dlitvakb I'm getting a slightly different problem here. Linked assets do now work, but not linked entries.

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 4, 2016

@frankmarineau Looking into it early tomorrow.

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 5, 2016

@frankmarineau new version of the contentful gem has been released addressing this issue.

Could you update and let me know if it works now?

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 5, 2016

Issue is still persistent on assets that are localized (entries now work fine).

Fix was found and currently adding specs around the feature.

New version will be published within the next few hours or early tomorrow.

cc @frankmarineau @martzoukos

@dlitvakb
Copy link
Contributor

dlitvakb commented Oct 6, 2016

Hey @frankmarineau @martzoukos,

Version 1.4.2 of contentful_middleman was just released fixing this issue.

Please let me know if everything works for you now.

Cheers

@martzoukos
Copy link

Yes, it works!

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants