Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Emerging TypoScript Best Practices - InspiringCon 2016

Emerging TypoScript Best Practices - InspiringCon 2016

This presentation has been held by Sebastian Kurfürst @InspiringCon 2016 in Kolbermoor.

Sebastian Kurfürst

April 23, 2016
Tweet

More Decks by Sebastian Kurfürst

Other Decks in Technology

Transcript

  1. # custom TypoScript prototype(TYPO3.Neos.NodeTypes:Image)[email protected] = false # Default definition of

    Image TS Object
 prototype(TYPO3.Neos.NodeTypes:Image) {
 ... [email protected] = TYPO3.Neos:ConvertUris {
 forceConversion = true
 }
 } Dependency Ordering crucial!
  2. TypoScript prototypes for page objects page = Page { ....

    } Old # COPY (bad!) specialPage < page { .... } root.special { condition = ${....} renderPath = '/specialPage' } prototype(Site:MyObject) < prototype(Page) { .... } page = Site:MyObject Recommended prototype(Site:Special) < prototype(Site:MyObject) { .... } root.special { condition = ${....} type = 'Site:Special' }
  3. How? prototype(MyTextWithImage) < prototype(TYPO3.Neos:Content) { image = MyImage { image

    = ${q(node).property('image')} } ... same for text element }
  4. prototype(Flowpack.SearchPlugin:SingleResult) < prototype(TYPO3.TypoScript:Case) { default { condition = Flowpack.SearchPlugin:CanRender {

    type = ${node.nodeType.name + 'SearchResult'} } type = ${node.nodeType.name + 'SearchResult'} } fallback { condition = TRUE type = 'TYPO3.Neos:DocumentSearchResult' } } Product Product ProductSearchResult
  5. <f:for each="{items}" as="item"> <li{ts:render(path:'{item.state}.attributes', context: {item: item}) -> f:format.raw()}> <neos:link.node

    node="{item.node}">{item.label}</neos:link.node> <f:if condition="{item.subItems}"> <ul> <f:render section="itemsList" arguments="{items: item.subItems}" /> </ul> </f:if> </li> </f:for> Fine to use e.g. for menus!
  6. Page Menu ContentCollection Text Plugin Image cached embed embed embed

    cached embed Page Cache Record Plugin Cache Record
  7. Page Menu ContentCollection Text Plugin Image cached embed embed embed

    uncached embed Page Cache Record always rendered dynamically
  8. Page Menu ContentCollection Text Plugin Image cached embed embed embed

    uncached embed always rendered dynamically What is currently being rendered? What is in the (TypoScript) context?
  9. What is currently being rendered? What is in the (TypoScript)

    context? prototype(Page) { @cache { mode = 'uncached' context { 1 = 'node' 2 = 'documentNode' } } }
  10. Basic Idea of caching Calculate Cache Entry Identifier Does Entry

    Identifier Exist In Cache? expensive calculation (such as rendering a page) Page Cache Record store in cache e.g. URL
  11. Configuring the Entry Identifier prototype(Page) { @cache { mode =

    'cached' entryIdentifier { // parts of the entry identifier node = ${node} editPreviewMode = ${node.context.currentRenderingMode.name} } } }
  12. Configuring the Entry Identifier prototype(Page) { @cache { mode =

    'cached' entryIdentifier { // parts of the entry identifier fixedIdentifier = 'Hello World' } } }
  13. There are only two hard things in Computer Science: cache

    invalidation and naming things. -- Phil Karlton
  14. When should the cache be flushed? Page Cache Record Everything

    Node_A.B Everything Node_A.B DescendantOf_A NodeType_X