Upload
bastian-waidelich
View
3.431
Download
5
Tags:
Embed Size (px)
DESCRIPTION
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.
Citation preview
FLOW3, Extbase & Fluid cook book June 15th 2012, Québec
Bastian Waidelich
2002 2008
THEORY
D D D
omain riven esign D D D
MODEL MODEL MODEL
Y R D
on‘t epeat ourself Y R D
Duplication is evil
S S I K
tupid imple t eep S S I K
In Phoenix: „MyWebsiteCom“
1. Put your site in an Extension/Package
Protect private folders with .htaccess files:
deny from all
2. Use Fluid for your site template
page = PAGE page { typeNum = 0 10 = FLUIDTEMPLATE 10 { file = EXT:my_website_com/Resources/Private/Templates/Site.html extbase.controllerExtensionName = MyWebsiteCom } }
page = PAGE page { typeNum = 0 10 = FLUIDTEMPLATE 10.file = EXT:my_website_com/Resources/Private/Templates/Site.html }
Specify extension name/package key for localisation & resources
page = TYPO3.TYPO3:Page page.body.templatePath = 'resource://MyWebsiteCom/Private/Templates/Site.html'
Phoenix:
DEMO
3. Layouts
page { … 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 } }
Solution 1: different templates
3. Layouts
page { … 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
Solution 2: CSS
3. Layouts
10 { … 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 } } }
Solution 3: Partials
<f:render partial="Content{layout}" />
Site.html
DEMO
Extension Package
4. Continuously enhance model
String comparison will be possible in Fluid! But it‘s mostly not needed.
<f:if condition="{paper.status} == 'accepted'"> <p>{paper.title} is accepted</p> </f:if> This will will not work!
Templates/Paper.html
4. Continuously enhance model
/** * @return boolean */ public function isAccepted() { return $this->status === self::STATUS_ACCEPTED; }
Model/Paper.php
<f:if condition="{paper.accepted} "> <p>{paper.title} is accepted</p> </f:if>
Templates/Paper.html
DEMO
5. Encapsulate your hacks
public 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); }
Controller/BookController.php
5. Encapsulate your hacks
public function tagCloudAction() { $tags = $this->tagCloudService->createTagCloud()); $this->view->assign('tags', $tags); }
Controller/BookController.php
<f:for each="{tags}" as="tag"> <span class="tag popularity-{tag.popularity}"> {tag.name} </span> </f:for>
Book/TagCloud.html
TagCloudService interacts with Database directly
DEMO
6. Performance
CACHING!
TCEMAIN.clearCacheCmd = 1,2,3
Storage folder TSConfig:
AJAX!
DEMO
THANK YOU @bwaidelich github.com/bwaidelich