Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaTexts and Anchors get lost - liquid templates #15425

Open
bashuss opened this issue Feb 29, 2024 · 4 comments
Open

MediaTexts and Anchors get lost - liquid templates #15425

bashuss opened this issue Feb 29, 2024 · 4 comments
Labels
Milestone

Comments

@bashuss
Copy link

bashuss commented Feb 29, 2024

Describe the bug

using OC 1.7
When accessing the media field, which is part of my BlogPost ContentType by Model.Content.BlogPost-Carousel
and passing it to new shape as parameter, Anchors and MediaTexts get lost. Paths are still available.

this creates the problem:
{{ "CarouselShape" | shape_new: Media: Model.Content.BlogPost-Carousel | shape_render }}

I get in CarouselShape:
{{ Model.Media.Paths | json }} => Array of paths
{{ Model.Media.MediaTexts | json }} => null
{{ Model.Media.Anchors | json }} => null

Calling in this way works for me:
{{ "CarouselShape" | shape_new: Media: Model.ContentItem.Content.BlogPost.Carousel | shape_render }}

To Reproduce

Steps to reproduce the behavior:

  1. Create or edit a ContentType "Test", with media field called "Carousel", which allows Anchors and MediaTexts
  2. Create a Template for ContentType "Test", named "Content__Test", which does something like this:
<div>
<h2>this fails: Model.Content.Test-Carousel</h2>
{{ "TestShape" | shape_new: Media: Model.Content.Test-Carousel | shape_render }}
</div>
<div>
<h2>this works: Model.ContentItem.Content.Test.Carousel</h2>
{{ "TestShape" | shape_new: Media: Model.ContentItem.Content.Test.Carousel | shape_render }}
</div>
  1. Create a Template for Shape "TestShape", which does something like this:
<ul>
<li>Paths:  {{ Model.Media.Paths | json }}</li>
<li>MediaTexts: {{ Model.Media.MediaTexts | json }}</li>
<li>Anchors: {{ Model.Media.Anchors | json }}</li>
</ul>
  1. Create a ContentItem for Test ContentType with images, MediaTexts and Anchors
  2. Preview
  3. The result show different behavior for both calls, as described above.

Expected behavior

I would expect, when Paths are available, that also MediaTexts and Anchors are available in the same way.

@Skrypt
Copy link
Contributor

Skrypt commented Feb 29, 2024

Have you tried this?

<li>MediaTexts: {{ Model.Media.MediaTexts }}</li>
<li>Anchors: {{ Model.Media.Anchors }}</li>

@hishamco
Copy link
Member

Did you try it in OC 1.8.x?

@bashuss
Copy link
Author

bashuss commented Feb 29, 2024

Have you tried this?

<li>MediaTexts: {{ Model.Media.MediaTexts }}</li>
<li>Anchors: {{ Model.Media.Anchors }}</li>

No, but I tried this:

{% if Model.Media.MediaTexts %}
{% assign text = Model.Media.MediaTexts[index] %}
{% endif %}

Text was never set until I used the workaround described above.

@bashuss
Copy link
Author

bashuss commented Feb 29, 2024

Did you try it in OC 1.8.x?

No, still have problems with migrating my main menu handling in 1.8 - cannot get my front end to work properly. Just a matter of time, which I don't have enough right now. Will get back to you, when I had a chance to migrate.

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

No branches or pull requests

4 participants