-
Notifications
You must be signed in to change notification settings - Fork 67
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
DOC Document ability to loop over arrays in templates #517
DOC Document ability to loop over arrays in templates #517
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should make your recommended changes
Made the changes and rebased to resolve the conflict |
61664da
to
bc25f02
Compare
en/08_Changelogs/6.0.0.md
Outdated
@@ -33,6 +33,9 @@ CanonicalURLMiddleware::singleton()->setEnabledEnvs([ | |||
|
|||
### Other new features | |||
|
|||
- Native indexed PHP arrays can now be passed into templates and iterated over with `<% loop $MyArray %>`. Under the hood they are wrapped in [`ArrayList`](api:SilverStripe\View\ViewableData), so you can get the count using `$Count` and use `<% if $ArrayList %>` as a shortcut for `<% if $ArrayList.Count %>`. Other functionality from `ArrayList` such as filtering and sorting cannot be used on arrays since they don't have keys to filter or sort against. | |||
- Note that associative arrays will continue to be wrapped in `ArrayData`, which means you can access their values by key but may not be able to iterate over them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Note that associative arrays will continue to be wrapped in `ArrayData`, which means you can access their values by key but may not be able to iterate over them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are still wrapped if they're nested in an array/ArrayList - but you can't return them directly from a controller. I'm not sure if it's even worth mentioning assoc arrays here because their usage is inconsistent and confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not worth mentioning, since the work to deal with those was split out into silverstripe/silverstripe-framework#11262
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bc25f02
to
800b318
Compare
Issue