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

Add CanRender check for ContentCase, add opinionated ".ListItem"-rendering #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The idea is very simple: you often need to display list of things (e.g. news, ar
2. If you want a paginated list, use `Flowpack.Listable:PaginatedCollection`.
3. If you just want a simple list, use `Flowpack.Listable:Collection` (or just `Neos.Fusion:Collection`!).
4. If you need a list with a header and an archive link, wrap you list into `Flowpack.Listable:List`
5. For each of your nodetypes create a new Fusion object of type NodeTypeName + '.Short', or manually define a rendering object.
5. For each of your nodetypes create a new Fusion object of type NodeTypeName + '.ListItem' or NodeTypeName + '.Short' (deprecated), or manually define a rendering object.
6. Rely on public API keys when overriding settings.

# Fusion objects
Expand All @@ -19,7 +19,7 @@ Keys documented here are considered public API and would be treated with semanti
## Flowpack.Listable:Collection

This object is just a simple convienince wrapper around `Neos.Fusion:Collection`, use it if you want to save a few keystrokes.
It wraps the list with UL and LI tags with a provided name and also set `Flowpack.Listable:ContentCaseShort` as a default for itemRenderer.
It wraps the list with UL and LI tags with a provided name and also set `Flowpack.Listable:ContentCase` as a default for itemRenderer.

Configuration options:

Expand All @@ -42,7 +42,7 @@ prototype(My.Custom:Object) < prototype(Flowpack.Listable:Collection) {
}
```

It would use the object `Something.Custom:Here.Short` for rendering each item.
It would use the object `Something.Custom:Here.ListItem` for rendering each item.

Make sure to correctly configure the cache.

Expand Down Expand Up @@ -73,7 +73,7 @@ prototype(My.Custom:Object) < prototype(Flowpack.Listable:PaginatedCollection) {
```

If you have additional URL parameters (e.g for a date filter) you have to register the argument and change the cache entryDiscriminator in order work accordingly.
HINT: Do not forget to register a corresponding route for your custom argument.
HINT: Do not forget to register a corresponding route for your custom argument.

```
prototype(My.Custom:Object) < prototype(Flowpack.Listable:PaginatedCollection) {
Expand All @@ -87,7 +87,7 @@ prototype(My.Custom:Object) < prototype(Flowpack.Listable:PaginatedCollection) {
entryDiscriminator = ${request.arguments.currentPage + request.arguments.date}
}

}
}
```

This object is configured by default to `dynamic` cache mode for pagination to work. All you have to do is add correct `entryTags` and you are all set.
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Collection.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ prototype(Flowpack.Listable:Collection) < prototype(Neos.Fusion:Collection) {
collection = 'must-be-set'
itemName = 'node'
iterationName = 'iteration'
itemRenderer = Flowpack.Listable:ContentCaseShort
itemRenderer = Flowpack.Listable:ContentCase
itemRenderer.@process.tmpl = ${'<li class="' + itemClass + '">' + value + '</li>'}
}
20 changes: 16 additions & 4 deletions Resources/Private/Fusion/Utility.fusion
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# This object is used to render items in a list automatically with object of type ObjectType + Short
prototype(Flowpack.Listable:ContentCaseShort) < prototype(Neos.Neos:ContentCase) {
default {
@position = 'end'
condition = true
prototype(Flowpack.Listable:ContentCase) < prototype(Neos.Neos:ContentCase) {
nodeTypeListItem {
@position = 'start 100'
condition = Neos.Fusion:CanRender {
type = ${q(node).property('_nodeType.name') + '.ListItem'}
}
type = ${q(node).property('_nodeType.name') + '.ListItem'}
}
nodeTypeShort {
@position = 'start 200'
condition = Neos.Fusion:CanRender {
type = ${q(node).property('_nodeType.name') + '.Short'}
}
type = ${q(node).property('_nodeType.name') + '.Short'}
}
}

# Legacy compatibility
prototype(Flowpack.Listable:ContentCaseShort) < prototype(Flowpack.Listable:ContentCase)