Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

FLOW3, Extbase & Fluid cook book

4,166 views

Published on

Slides from my talk at T3CON12CA.
See https://github.com/bwaidelich/Extensions.my_website_com and https://github.com/bwaidelich/Extensions.books for the corresponding TYPO3 Extensions.

Published in: Technology, Design
  • Be the first to comment

  • Be the first to like this

FLOW3, Extbase & Fluid cook book

  1. 1. FLOW3,Extbase &Fluidcook book June 15th 2012, Québec
  2. 2. Bastian Waidelich
  3. 3. 20022008
  4. 4. THEORY
  5. 5. DDD
  6. 6. D D Domain riven esign
  7. 7. MODELMODEL MODEL
  8. 8. DRY
  9. 9. D R Yon‘t epeat ourself
  10. 10. Duplicationis evil
  11. 11. KISS
  12. 12. K IS S eep t imple tupid
  13. 13. 1. Put your site in an Extension/Package In Phoenix: „MyWebsiteCom“ Protect private folders with .htaccess files: deny from all
  14. 14. 2. Use Fluid for your site templatepage = PAGEpage { typeNum = 0 10 = FLUIDTEMPLATE 10.file = EXT:my_website_com/Resources/Private/Templates/Site.html 10 {} file = EXT:my_website_com/Resources/Private/Templates/Site.html extbase.controllerExtensionName = MyWebsiteCom }} Specify extension name/package key for localisation & resourcesPhoenix:page = TYPO3.TYPO3:Pagepage.body.templatePath = resource://MyWebsiteCom/Private/Templates/Site.html
  15. 15. DEMO
  16. 16. 3. LayoutsSolution 1: different templatespage { … 10 = FLUIDTEMPLATE 10 { … file = CASE file { key.data = levelfield:-1,backend_layout_next_level,slide key.override.field = backend_layout default = TEXT default.value = EXT:my_website_com/…/Default.html 2 = TEXT 2.value = EXT:my_website_com/…/Wide.html }}
  17. 17. 3. LayoutsSolution 2: CSSpage {… bodyTagCObject = CASE bodyTagCObject { key.data = levelfield:-1,backend_layout_next_level,slide key.override.field = backend_layout default = TEXT default.value = <body> 2 = TEXT 2.value = <body class="wide"> }}Very clean, but not always possible
  18. 18. 3. LayoutsSolution 3: Partials10 { … variables { … layout = CASE layout { key.data = levelfield:-1,backend_layout_next_level,slide key.override.field = backend_layout default = TEXT default.value = Default 2 = TEXT 2.value = Wide } }}Site.html<f:render partial="Content{layout}" />
  19. 19. DEMO
  20. 20. Extension Package
  21. 21. 4. Continuously enhance modelTemplates/Paper.html<f:if condition="{paper.status} == accepted"> <p>{paper.title} is accepted</p></f:if> This will will not work!String comparison will be possible in Fluid!But it‘s mostly not needed.
  22. 22. 4. Continuously enhance modelModel/Paper.php/** * @return boolean */public function isAccepted() { return $this->status === self::STATUS_ACCEPTED;}Templates/Paper.html<f:if condition="{paper.accepted} "> <p>{paper.title} is accepted</p></f:if>
  23. 23. DEMO
  24. 24. 5. Encapsulate your hacksController/BookController.phppublic function tagCloudAction() { $books = $this->bookRepository->findAll(); $tags = array(); foreach ($books as $book) { foreach ($book->getTags() as $tag) { $tagCount = 1; if (isset($tags[$tag->getTitle()])) { $tagCount ++; $tags[$tag->getTitle()] = $tagCount; } } $this->view->assign(tags, $tags);}
  25. 25. 5. Encapsulate your hacksController/BookController.phppublic function tagCloudAction() { $tags = $this->tagCloudService->createTagCloud()); $this->view->assign(tags, $tags);}TagCloudService interacts with Database directlyBook/TagCloud.html<f:for each="{tags}" as="tag"> <span class="tag popularity-{tag.popularity}"> {tag.name} </span></f:for>
  26. 26. DEMO
  27. 27. 6. PerformanceCACHING!Storage folder TSConfig:TCEMAIN.clearCacheCmd = 1,2,3AJAX!
  28. 28. DEMO
  29. 29. THANK YOU@bwaidelichgithub.com/bwaidelich

×