Your SlideShare is downloading. ×
0
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
How I Stopped Worrying and Learned to Love Typoscript
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

How I Stopped Worrying and Learned to Love Typoscript

4,637

Published on

TypoScript best practices in relation to ext development

TypoScript best practices in relation to ext development

Published in: Technology, Education
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,637
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
84
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
































  • Transcript

    • 1. HOW I STOPPED WORRYING AND LEARNED TO LOVE TypoScript Zach Davis Cast Iron Coding
    • 2. Obstacles to Seeing the Utility of TypoScript • Unfashionable: TypoScript represents configuration over convention for many developers • Challenging: too much like code for many beginners
    • 3. Attempts to Address These Obstacles • Object Oriented TypoScript - circa 2005 as an attempt to recast TypoScript for developers • Template Auto-parser and TemplaVoila as ways to avoid having to learn too much TypoScript
    • 4. Why TypoScript Made Me Worry • Idiosyncratic naming conventions • aTagParams or ATagParams? • stripHtml vs. removeBadHTML • Underscores or CamelCase? • Property positions not always intuitive • IMAGE.file.width or IMAGE.width?
    • 5. Why TypoScript Made Me Worry • Learning to Navigate the TSREF is Challenging • Because properties can be functions, data types, or even other cObj types, readers make many passes through the TSREF to find what they seek • Improved linking in the TSREF would go a long way - CIC volunteers to help!
    • 6. Why TypoScript Made Me Worry • No clear set of TypoScript Best Practices, as there is for TYPO3 PHP code • Lack of best practices leads to many interpretations of TypoScript • Many interpretations means users often aren’t able to take knowledge gained from the TSREF or from one extension and apply it to a new extension
    • 7. TT_NEWS, For Example
    • 8. TT_NEWS, For Example
    • 9. TT_NEWS, For Example
    • 10. TT_NEWS, For Example
    • 11. TT_NEWS, For Example
    • 12. From TypoScript to Output TypoScript: $conf Database Record email_stdWrap.wrap Email: | email zach@cic.com PLUGIN INSTANCE date_stdWrap.wrap Date: | date 4/1/2009 author_stdWrap.wrap Author: | author Zach Davis Marker Array Email: field_email zach@cic.com Date: field_date 4/1/2009 Author: Zach field_author Davis
    • 13. It works, and it’s worked for a long time. But we can do better.
    • 14. Do we really need a new approach? • Limiting rendering of a marker to stdWrap is unnecessarily limiting. Why ignore the wealth of functionality in tslib_cObj? • What if I need a custom field and a corresponding custom marker? Do I modify the PHP? Do I XCLASS it? Hope for a hook?
    • 15. Do we really need a new approach? • Certainly, some TypoScript contains control logic (how many records to list, which view to display, etc). • However, a lot of TypoScript is really presentation logic, and as such should not be hardcoded into the extension PHP class.
    • 16. Do we really need a new approach? • Yes! Let’s avoid idiosyncratic TypoScript properties. • If each marker has stdWrap available as stdWrap, for example, users don’t need to remember extension-specific properties.
    • 17. The Solution! $cObj = t3lib_div::makeInstance('tslib_cObj'); foreach($records as $row) { $cObj->start($row,'tx_dam'); foreach($markerConf as $key => $value) { if(is_string($value)) { $type = $value; $conf = $markerConf[$key.'.']; $markerValues['###'.$key.'###'] = $cObj->cObjGetSingle($type,$conf); } } }
    • 18. The Solution! $cObj = t3lib_div::makeInstance('tslib_cObj'); foreach($records as $row) { $cObj->start($row,'tx_dam'); foreach($markerConf as $key => $value) { if(is_string($value)) { $type = $value; $conf = $markerConf[$key.'.']; $markerValues['###'.$key.'###'] = $cObj->cObjGetSingle($type,$conf); } } }
    • 19. The Solution! $cObj = t3lib_div::makeInstance('tslib_cObj'); foreach($records as $row) { $cObj->start($row,'tx_dam'); foreach($markerConf as $key => $value) { if(is_string($value)) { $type = $value; $conf = $markerConf[$key.'.']; $markerValues['###'.$key.'###'] = $cObj->cObjGetSingle($type,$conf); } } }
    • 20. The Solution! $cObj = t3lib_div::makeInstance('tslib_cObj'); foreach($records as $row) { $cObj->start($row,'tx_dam'); foreach($markerConf as $key => $value) { if(is_string($value)) { $type = $value; $conf = $markerConf[$key.'.']; $markerValues['###'.$key.'###'] = $cObj->cObjGetSingle($type,$conf); } } }
    • 21. The Solution! $cObj = t3lib_div::makeInstance('tslib_cObj'); markers { foreach($records as $row) { image = IMAGE $cObj->start($row,'tx_dam'); title = TEXT foreach($markerConf as $key => $value) { } if(is_string($value)) { $type = $value; $conf = $markerConf[$key.'.']; $markerValues['###'.$key.'###'] = $cObj->cObjGetSingle($type,$conf); } } }
    • 22. ONE ONE ONE FIELD PROPERTY MARKER Database Record TypoScript: $conf Marker Array Email: email zach@cic.com email_stdWrap.wrap Email: | field_email zach@cic.com Date: date 4/1/2009 date_stdWrap.wrap Date: | field_date 4/1/2009 Author: Zach author Zach Davis author_stdWrap.wrap Author: | field_author Davis
    • 23. email = TEXT wrap Email: | typolink.parameter.field email Database Record Marker Array date = TEXT email zach@cic.com field_email Email: zach@cic.com wrap Date: | Date: date 4/1/2009 field_date 4/1/2009 stdWrap.strftime %D %T author_uid 29 field_author Author: Zach Davis author_name Zach Davis author = TEXT wrap Author: | field author_name typolink.parameter 10 typolink.ATagParams &tx_myext_pi1[author]={field:author_uid} typolink.ATagParams. 1 insertData
    • 24. The Solution! $cObj = t3lib_div::makeInstance('tslib_cObj'); markers { foreach($records as $row) { image = IMAGE $cObj->start($row,'tx_dam'); title = TEXT foreach($markerConf as $key => $value) { } if(is_string($value)) { $type = $value; $conf = $markerConf[$key.'.']; $markerValues['###'.$key.'###'] = $cObj->cObjGetSingle($type,$conf); } } }
    • 25. If you’re creating TypoScript templates, you’re probably doing this already. lib.pageTitle = TEXT lib.pageTitle.field = title
    • 26. The Solution! $cObj = t3lib_div::makeInstance('tslib_cObj'); markers { foreach($records as $row) { image = IMAGE $cObj->start($row,'tx_dam'); title = TEXT foreach($markerConf as $key => $value) { } if(is_string($value)) { $type = $value; $conf = $markerConf[$key.'.']; $markerValues['###'.$key.'###'] = $cObj->cObjGetSingle($type,$conf); } } }
    • 27. Why write TS like this... title_stdWrap.wrap = subheader_stdWrap.stripHtml = 1 subheader_stdWrap.crop = 230 | ... | 1 subheader_stdWrap.ifEmpty.field = bodytext author_stdWrap.wrap = preAuthor_stdWrap.noTrimWrap = || | imageCount=1 imageWrapIfAny =
    • 28. ...when it can look like this? views { single { markers { title = TEXT title.wrap = <h1>|</h1> title.field = title body = TEXT body.parseFunc < lib.parseFunc_RTE body.field = bodytext } } }
    • 29. ...when it can look like this? views { single { markers { title = TEXT title.wrap = <h1>|</h1> title.field = title body = TEXT body.parseFunc < lib.parseFunc_RTE body.field = bodytext image = IMAGE image.file.import.field = image } } }
    • 30. ...when it can look like this? views { single { markers { title = TEXT title.wrap = <h1>|</h1> title.field = title title.if.isTrue.field = title body = TEXT body.parseFunc < lib.parseFunc_RTE body.field = bodytext image = IMAGE image.file.import.field = image isFriendIcon = USER_INT isFriendIcon.userFunc = myClass->method } } }

    ×