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

Using limit() on collection breaks iterator.isLast #161

Open
samsauter opened this issue Dec 16, 2016 · 0 comments
Open

Using limit() on collection breaks iterator.isLast #161

samsauter opened this issue Dec 16, 2016 · 0 comments

Comments

@samsauter
Copy link

samsauter commented Dec 16, 2016

I have the following setup to limit a collection and return it as json. But iterator.isLast is not true in the last cycle, so the json format is wrong because the last ',' is not removed. Did I miss something in the config or my fusion setup?

prototype(Vendor.Site:NewsListJson) < prototype(TYPO3.TypoScript:Collection) {
	collection = ${Search.query(site).nodeType('Vendor.Site:News').sortDesc('date').limit(5).execute()}
	itemName = 'node'
	iterationName = 'iterator'
	itemRenderer = Vendor.Site:NewsListItemJson {

	}

	@process.1 = ${'[' + value + ']'}
	@cache {
		mode = 'cached'
		entryTags {
			1 = ${'NodeType_Vendor.Site:News'}
		}
	}
}
prototype(Vendor.Site:NewsListItemJson) < prototype(Vendor.Site:JsonObjectRenderer) {
	id = ${q(node).property('uriPathSegment')}
	title = ${String.stripTags(q(node).property('title'))}
	text = ${String.crop(q(node).property('text'), 150, '...')}
	image = TYPO3.Neos:ImageUri {
		asset = ${q(node).property('image')}
		maximumWidth = 80
		maximumHeight = 60
		allowCropping = TRUE
		allowUpScaling = TRUE
	}
	entryDate = ${Date.format(q(node).property('date'), 'F jS, Y')}
	category = ${q(node).property('category')}
}
prototype(Vendor.Site:JsonObjectRenderer) < prototype(TYPO3.TypoScript:RawArray) {
	@process.1 = ${Json.stringify(value)}
	@process.2 = ${'' + value}
	@process.3 = ${iterator.isLast ? value : value + ','}
}

Output of ${iterator}:
[{"index":0,"cycle":1,"isFirst":true,"isLast":false,"isEven":false,"isOdd":true},{"index":1,"cycle":2,"isFirst":false,"isLast":false,"isEven":true,"isOdd":false},{"index":2,"cycle":3,"isFirst":false,"isLast":false,"isEven":false,"isOdd":true},{"index":3,"cycle":4,"isFirst":false,"isLast":false,"isEven":true,"isOdd":false},{"index":4,"cycle":5,"isFirst":false,"isLast":false,"isEven":false,"isOdd":true},]

Using:
Flowpack.ElasticSearch.ContentRepositoryAdaptor from master branch
Neos 2.3.8

Thank you.

@samsauter samsauter changed the title Limiting collection breaks iterator.isLast Using limit() on collection breaks iterator.isLast Dec 16, 2016
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

1 participant