Skip to content

Instantly share code, notes, and snippets.

@dfeyer
Last active August 29, 2015 14:17
Show Gist options
  • Save dfeyer/44a75fba60d8cceba440 to your computer and use it in GitHub Desktop.
Save dfeyer/44a75fba60d8cceba440 to your computer and use it in GitHub Desktop.
Simple Neos Menu to list 4 recent news in a Menu (require EEL sort opertation)
# Solution 1
# Based on the default TypoScript2 Menu implementation
recentNewsMenu = TYPO3.TypoScript:Menu {
templatePath = 'resource://Your.Package/Private/Templates/NodeTypes/Menu.html'
filter = 'Your.Package:News'
items.@process.sort = ${q(value).count() > 0 ? q(value).sort('publishedDate', 'DESC').get() : value}
items.@process.slice = ${q(value).count() > 0 ? q(value).slice(0, 4).get() : value}
}
# Solution 2
# A custom EEL opertation can help basic user
# The custom EEL operation can be generic (handle any document type) and accept a node property (sorting) and the number of article
recentNewsMenu = TYPO3.TypoScript:Menu {
templatePath = 'resource://Your.Package/Private/Templates/NodeTypes/Menu.html'
filter = 'Your.Package:News'
items.@process.recentDocument = ${q(value).recentDocument('publishedDate', 3).get()}
}
# Solution 3
# The same menu but based on ElasticSearch for the Query (if the current project has a huge number of documents)
recentNewsMenu = TYPO3.TypoScript:Menu {
templatePath = 'resource://Your.Package/Private/Templates/NodeTypes/Menu.html'
items = ${Search.query(site).nodeType('Your.Package:News').sortDesc('publishedDate').limit(4).execute()}
}
# Solution 4
# If menu with recent document list is common in the project, the configuration can be simplified and generic, this kind of TS2 prototype can be stored in a central package and shared between project
prototype(Your.Package:RecentDocumentMenu) < prototype(TYPO3.TypoScript:Menu) {
templatePath = 'resource://Your.Package/Private/Templates/NodeTypes/Menu.html'
sortingPropertyName = 'publishedDate'
items.@process.recentDocument = ${q(value).recentDocument(this.sortingPropertyName, 3).get()}
}
recentNewsMenu = Your.Package:RecentDocumentMenu {
filter = 'Your.Package:News'
}
recentProductMenu = Your.Package:RecentDocumentMenu {
filter = 'Your.Package:Product'
sortingPropertyName = 'lastUpdate'
}
# Solution 1 with cache configuration
# You can clear the cache of this specific component, by configuring the cache segment
# So when a docuement of type Your.Package:News is created / edited, the cache segment will be deleted (not the full page, just this componenent)
recentNewsMenu = TYPO3.TypoScript:Menu {
templatePath = 'resource://Your.Package/Private/Templates/NodeTypes/Menu.html'
filter = 'Your.Package:News'
items.@process.sort = ${q(value).count() > 0 ? q(value).sort('publishedDate', 'DESC').get() : value}
items.@process.slice = ${q(value).count() > 0 ? q(value).slice(0, 4).get() : value}
@cache {
entryTags {
1 = 'NodeType_Your.Package:News'
}
}
}
@dfeyer
Copy link
Author

dfeyer commented Mar 17, 2015

Un développeur peut créer des nouvelles opération EEL ou des prototypes TS2, alors que l'intégrateur se concentre sur le développement des composants de présentation du contenu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment