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

Talltales
TalltalesTalltales
TalltalesPEDH
 
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 partNaoko Kawachi
 
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 CollaborationBernice Glenn
 
Autobiography
AutobiographyAutobiography
AutobiographyPEDH
 
Lesson 13 vocab
Lesson 13 vocabLesson 13 vocab
Lesson 13 vocabPEDH
 
Theme 1 Volcanoes Vocabulary2
Theme 1 Volcanoes Vocabulary2Theme 1 Volcanoes Vocabulary2
Theme 1 Volcanoes Vocabulary2PEDH
 
World Coolest Intern - Case Study
World Coolest Intern - Case StudyWorld Coolest Intern - Case Study
World Coolest Intern - Case StudyAman Narain
 
Wiki Women Camp 2012 IIEF Report
Wiki Women Camp 2012 IIEF ReportWiki Women Camp 2012 IIEF Report
Wiki Women Camp 2012 IIEF ReportWikimedia Indonesia
 
Hannah Montana
Hannah MontanaHannah Montana
Hannah Montanaamoto
 
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
 
@BettyDraper's Guide to Social Storytelling
@BettyDraper's Guide to Social Storytelling@BettyDraper's Guide to Social Storytelling
@BettyDraper's Guide to Social StorytellingHelen Klein Ross
 
Kelas Menulis Wikipedia I - Hendra
Kelas Menulis Wikipedia I - HendraKelas Menulis Wikipedia I - Hendra
Kelas Menulis Wikipedia I - HendraWikimedia Indonesia
 
IAサミットは誰のものか
IAサミットは誰のものかIAサミットは誰のものか
IAサミットは誰のものかNaoko Kawachi
 
Proposal Bebaskan Pengetahuan 2012
Proposal Bebaskan Pengetahuan 2012Proposal Bebaskan Pengetahuan 2012
Proposal Bebaskan Pengetahuan 2012Wikimedia Indonesia
 
Proyek penciptaan dan digitalisasi konten
Proyek penciptaan dan digitalisasi kontenProyek penciptaan dan digitalisasi konten
Proyek penciptaan dan digitalisasi kontenWikimedia 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

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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