SlideShare a Scribd company logo
1 of 32
HOW I STOPPED
WORRYING AND LEARNED
  TO LOVE TypoScript
        Zach Davis
      Cast Iron Coding
Obstacles to Seeing the
       Utility of TypoScript

•   Unfashionable:
    TypoScript represents
    configuration over
    convention for many
    developers

•   Challenging: too much
    like code for many
    beginners
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
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?
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!
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
TT_NEWS, For Example
TT_NEWS, For Example
TT_NEWS, For Example
TT_NEWS, For Example
TT_NEWS, For Example
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
It works, and it’s worked for a
           long time.
    But we can do better.
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?
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.
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.
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);
        }
    }
}
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);
        }
    }
}
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);
        }
    }
}
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);
        }
    }
}
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);
        }
    }
}
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
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
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);
        }
    }
}
If you’re creating TypoScript
 templates, you’re probably
     doing this already.

   lib.pageTitle = TEXT
   lib.pageTitle.field = title
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);
        }
    }
}
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 =
...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
  
    
    }
  
    }
  }
...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
  
    
    }
  
    }
  }
...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
  
    
    }
  
    }
  }

More Related Content

Viewers also liked

Autobiography
AutobiographyAutobiography
Autobiography
PEDH
 
Lesson 13 vocab
Lesson 13 vocabLesson 13 vocab
Lesson 13 vocab
PEDH
 
Theme 1 Volcanoes Vocabulary2
Theme 1 Volcanoes Vocabulary2Theme 1 Volcanoes Vocabulary2
Theme 1 Volcanoes Vocabulary2
PEDH
 
Hannah Montana
Hannah MontanaHannah Montana
Hannah Montana
amoto
 
What can Michelangelo teach us about innovation?
What can Michelangelo teach us about innovation?What can Michelangelo teach us about innovation?
What can Michelangelo teach us about innovation?
Aman Narain
 
Kelas Menulis Wikipedia I - Hendra
Kelas Menulis Wikipedia I - HendraKelas Menulis Wikipedia I - Hendra
Kelas Menulis Wikipedia I - Hendra
Wikimedia Indonesia
 

Viewers also liked (18)

Organisasi Dan Proyek
Organisasi Dan ProyekOrganisasi Dan Proyek
Organisasi Dan Proyek
 
Jorge Caballero Peru Lac English Final
Jorge Caballero Peru Lac English FinalJorge Caballero Peru Lac English Final
Jorge Caballero Peru Lac English Final
 
Talltales
TalltalesTalltales
Talltales
 
IA Summit 2011 Redux in Tokyo -naoko's part
IA Summit 2011 Redux in Tokyo -naoko's partIA Summit 2011 Redux in Tokyo -naoko's part
IA Summit 2011 Redux in Tokyo -naoko's part
 
Web Quests: for Adult e-Learning For Adult Learning And Collaboration
Web Quests:  for Adult e-Learning For Adult Learning And CollaborationWeb Quests:  for Adult e-Learning For Adult Learning And Collaboration
Web Quests: for Adult e-Learning For Adult Learning And Collaboration
 
Autobiography
AutobiographyAutobiography
Autobiography
 
Lesson 13 vocab
Lesson 13 vocabLesson 13 vocab
Lesson 13 vocab
 
Theme 1 Volcanoes Vocabulary2
Theme 1 Volcanoes Vocabulary2Theme 1 Volcanoes Vocabulary2
Theme 1 Volcanoes Vocabulary2
 
World Coolest Intern - Case Study
World Coolest Intern - Case StudyWorld Coolest Intern - Case Study
World Coolest Intern - Case Study
 
Wiki Women Camp 2012 IIEF Report
Wiki Women Camp 2012 IIEF ReportWiki Women Camp 2012 IIEF Report
Wiki Women Camp 2012 IIEF Report
 
Hannah Montana
Hannah MontanaHannah Montana
Hannah Montana
 
Papat limpad
Papat limpadPapat limpad
Papat limpad
 
What can Michelangelo teach us about innovation?
What can Michelangelo teach us about innovation?What can Michelangelo teach us about innovation?
What can Michelangelo teach us about innovation?
 
@BettyDraper's Guide to Social Storytelling
@BettyDraper's Guide to Social Storytelling@BettyDraper's Guide to Social Storytelling
@BettyDraper's Guide to Social Storytelling
 
Kelas Menulis Wikipedia I - Hendra
Kelas Menulis Wikipedia I - HendraKelas Menulis Wikipedia I - Hendra
Kelas Menulis Wikipedia I - Hendra
 
IAサミットは誰のものか
IAサミットは誰のものかIAサミットは誰のものか
IAサミットは誰のものか
 
Proposal Bebaskan Pengetahuan 2012
Proposal Bebaskan Pengetahuan 2012Proposal Bebaskan Pengetahuan 2012
Proposal Bebaskan Pengetahuan 2012
 
Proyek penciptaan dan digitalisasi konten
Proyek penciptaan dan digitalisasi kontenProyek penciptaan dan digitalisasi konten
Proyek penciptaan dan digitalisasi konten
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

How I Stopped Worrying and Learned to Love Typoscript

  • 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
  • 12.
  • 13. 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
  • 14. It works, and it’s worked for a long time. But we can do better.
  • 15. 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?
  • 16. 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.
  • 17. 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.
  • 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.
  • 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'); 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); } } }
  • 22. 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); } } }
  • 23. 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); } } }
  • 24. 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
  • 25. 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
  • 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. If you’re creating TypoScript templates, you’re probably doing this already. lib.pageTitle = TEXT lib.pageTitle.field = title
  • 28. 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); } } }
  • 29. 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 =
  • 30. ...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 } } }
  • 31. ...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 } } }
  • 32. ...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 } } }

Editor's Notes