How I Stopped Worrying and Learned to Love Typoscript

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    4 Favorites & 1 Event

    How I Stopped Worrying and Learned to Love Typoscript - Presentation 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 } } }

    + zdaviszdavis, 7 months ago

    custom

    1375 views, 4 favs, 1 embeds more stats

    TypoScript best practices in relation to ext develo more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1375
      • 1349 on SlideShare
      • 26 from embeds
    • Comments 0
    • Favorites 4
    • Downloads 34
    Most viewed embeds
    • 26 views on http://www.bertrandkeller.info

    more

    All embeds
    • 26 views on http://www.bertrandkeller.info

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events