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

Collections not shown in Twig #1452

Closed
milosa opened this issue Jun 8, 2020 · 9 comments · Fixed by #1455 or #1485
Closed

Collections not shown in Twig #1452

milosa opened this issue Jun 8, 2020 · 9 comments · Fixed by #1455 or #1485
Labels
🐛 tag: bug This is a bug.

Comments

@milosa
Copy link

milosa commented Jun 8, 2020

Collections are not printed in the Twig templates.

When trying this example, the loop doesn't print anything.

Also, I noticed that when I print features|length in twig, I get some weird numbers.
I added 1 feature in the back end, so I’d expect it to print 1. But instead I got 4.
When I add another one, it should be 2, or maybe 8, but I got 11.

Even though features has elements (because it's length > 0), the stuff inside the loop doesn’t get executed.

Maybe it's related to #1438 or the fact that htmllang() is still empty and therefore the system doesn't know which translation to use (#1437)

Details

Question Answer
Relevant Bolt Version 4.0 RC 23
Install type Composer install
PHP version 7.4.6
Web server Symfony

Reproduction

Create new Bolt project. Add field to a contenttype from this example and use the for loop from that page as well.

Steps to reproduce

Add some data to the features field.

Expected result

Features are shown on the page with the for loop from the docs.

Actual result

Features are not shown.

@I-Valchev
Copy link
Member

hey @milosa the PR I mentioned above should resolve the |length issue. This should resolve it, if not let me know :-)

@milosa
Copy link
Author

milosa commented Jun 9, 2020

@I-Valchev The length is now correct. The for loop still doesn't print anything though.

@milosa
Copy link
Author

milosa commented Jun 9, 2020

I'm not sure if you're aware, but for me, the htmllang() is still empty. #1439
I have a feeling this might be related to this issue somehow.

@milosa
Copy link
Author

milosa commented Jun 9, 2020

@bobdenotter #1455 only fixes the |length part of this issue, right?

@bobdenotter bobdenotter reopened this Jun 11, 2020
@bobdenotter
Copy link
Member

Re-opened.

@benplummer
Copy link

I'm having the same problem with imagelist.

It works fine when retrieving the first image in a template e.g. {{ apartment | image | thumbnail(320, 240) }}

However, when I try to loop through the imagelist to display each image, the for loop does not seem to run. It seems as though the imagelist is empty.

@bobdenotter
Copy link
Member

I've updated the docs for this: bolt/docs#1048

PR with code changes to follow shortly.

@bobdenotter
Copy link
Member

@benplummer Latest commit to #1485 also fixes it for Imagelists.

@bobdenotter bobdenotter added the 🐛 tag: bug This is a bug. label Jun 16, 2020
@bobdenotter bobdenotter added this to the Bolt 4.0.0 stable milestone Jun 16, 2020
@benplummer
Copy link

@bobdenotter Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 tag: bug This is a bug.
Projects
None yet
4 participants