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

ListPart shape bug or just my missuse #4749

Closed
arkadiuszwojcik opened this issue Nov 6, 2019 · 8 comments
Closed

ListPart shape bug or just my missuse #4749

arkadiuszwojcik opened this issue Nov 6, 2019 · 8 comments

Comments

@arkadiuszwojcik
Copy link
Contributor

Shapes still brings some confusion to me. I have Book content item that have AliasPart AutoroutePart and ListPart of BookChapters then my Content-Book.liquid shape have such line:

{% assign book_chapters = Model.Content.ListPart.ContentItems | contet_of_type: "BookChapter" %}

When accesing Book by link thanks to AutoroutePart , shape for ListPart is generated, so ListPart is populated with BookChapters. Thats is correct.

But in other place of my website I have such liquid code:

{{ Content["alias:my-book"] | shape_build_display | shape_render }}

This time book content itself is loaded, it also starts to render Content-Book.liquid shape, but ListPart is not populated with BookChapters items. This suggest that in this second case ListPart shape is not properly constucted, so it is not loadind BookChapters .

Any thoughts on this?

@arkadiuszwojcik
Copy link
Contributor Author

arkadiuszwojcik commented Nov 7, 2019

I have some extra clue. My hierarchy looks like this: Author -> List of Book -> List of Chapters When I do experiments with Author itself and try to list all Books everything works fine. But when I go one level down (starting from Book level and trying to list all Chapters like described in first thread) then it doesn't work. Conclusion is that error is related to nested ListPart

By the way: I guess same error is responsible for missing list of chapters in Admin when I edit Book content object. When I edit Author in admin menu I can see list of all books, but when I want to edit Book I can't see list of chapters.

@deanmarcussen
Copy link
Member

I have used ListPart's to nest content similarly to your heirachy, but mostly with Razor.

This confuses me

{{ Content["alias:my-book"] | shape_build_display | shape_render }}

Are you intending to load a particular content item based on it's alias and render it?
Or have I misunderstood?

@arkadiuszwojcik
Copy link
Contributor Author

@deanmarcussen exactly, and this content item contains ListPart of other objects.

@deanmarcussen
Copy link
Member

How are you loading the content item you want?
With the content_item_id filter?

@arkadiuszwojcik
Copy link
Contributor Author

No, by alias: {{ Content["alias:my-book"] | shape_build_display | shape_render }} look at: Content["alias:my-book"]

@arkadiuszwojcik
Copy link
Contributor Author

arkadiuszwojcik commented Nov 7, 2019

When I access very same Book Content Item but by it's URL then ListPart with Chapters is loaded and everything works fine.

@sebastienros
Copy link
Member

Depending on the type of the template you are editing, Model.Content.ListPart means different things.
Model.Content could be the Json of a content item, and .ContentItems will be availble. But in a Content-XYZ template it will mean the ListPart shape in the Content zone, which might not have this property.

@arkadiuszwojcik
Copy link
Contributor Author

@sebastienros I think you are right here my real use case is actually slightly diffrent (sorry for missing that):

{{ Content["alias:my-book"] | shape_build_display "ListItem" | shape_render }} so it means that template engine will look for "ListPart.ListItem.liquid" while rendering ListPart for Content-Book.ListItem.liquid ? And it can't find one so ListPart is empty? If so is there any way to use Content-Book.ListItem.liquid but force regular ListPart shape?

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

No branches or pull requests

4 participants