Last active
August 29, 2015 14:17
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
[email protected] = ${q(value).count() > 0 ? q(value).sort('publishedDate', 'DESC').get() : value} | |
[email protected] = ${q(value).count() > 0 ? q(value).slice(0, 4).get() : value} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
[email protected] = ${q(value).recentDocument('publishedDate', 3).get()} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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()} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
[email protected] = ${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' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
[email protected] = ${q(value).count() > 0 ? q(value).sort('publishedDate', 'DESC').get() : value} | |
[email protected] = ${q(value).count() > 0 ? q(value).slice(0, 4).get() : value} | |
@cache { | |
entryTags { | |
1 = 'NodeType_Your.Package:News' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.