[TYPO3-english] TS Code Reuse

Scotty C superscotty19 at yahoo.com
Tue Apr 7 08:56:54 CEST 2015


Ignore my last message!!!
I GOT IT!
It made so much sense when I applied your code as separate objects. My solution (in case anybody else wants to do this) is:
Constants:
test1 = TEST1test1Path = /fileadmin/test1test2 = TEST2test2Path = /fileadmin/test2

Setup:
temp.Gallery = TEXTtemp.Gallery {   ... bunch of code ...}
  temp.category = TEXT  temp.category {    value = Default Category    wrap = <h2 class="open">|</h2>    case = capitalize  }      page.10.20 < temp.category  page.10.20.value = {$education}  page.10.21 < temp.templateGallerypage.10.21.filelist = {$educationPath}||name||0page.10.21.split.1.filelink.path = {$educationPath}page.10.21.split.1.filelink.iconCObject.file.import = {$educationPath}
  page.10.30 < temp.category  page.10.30.value = {$events}
page.10.31 < temp.templateGallerypage.10.31.filelist = {$eventsPath}||name||0page.10.31.split.1.filelink.path = {$eventsPath}page.10.31.split.1.filelink.iconCObject.file.import = {$eventsPath}

page.19 = TEMPLATE page.19 {    template = FILE    template.file = fileadmin/breeze/version2/signup-template.html   workOnSubpart = DOCUMENT       marks.{$test1} < page.10.20
   marks.{$test1}.append < page.10.21   marks.{$test2} < page.10.30   marks.{$test2}.append < page.10.31} # end template

Thanks again for all the help - I'm figuring out the massive TS library slowly but surely!-Scott.

 
      From: bernd wilke <t3ng at bernd-wilke.net>
 To: typo3-english at lists.typo3.org 
 Sent: Thursday, March 26, 2015 1:42 AM
 Subject: Re: [TYPO3-english] TS Code Reuse
   
Am 26.03.15 um 04:34 schrieb Scotty C:
> Hi again,
> In my ongoing pursuit of defeating the TS monster, I have (hopefully) one more question and then I'll be good for a while ;-)
> I want to cleanup/minimize/optimize my code
> I have created a large chunk of TS, let's say:
> Constants:
title1 = <h1>Title1</h1>
title2 = <h1>Title2</h1>

my recommandation: don't mix values and wraps
you may define constants for vlaues and you may define constants for 
wraps, but distinct the usage:

title1= Title 1
title2= Title 2
titleWrap1 = <h1>|</h1>
titleWrap2 = <h2>|</h2>


> Setup:
temp.myFunc1 = TEXT
temp.myFunc1 {
    ...
    .... {$title1}
}
> temp.myFunc2 = TEXT
temp.myFunc2 {
    ...
    .... {$title2}
}
> myFunc1 and myFunc2 are exactly the same, except that myFunc1 references title1 and myFunc2 references title2. Is there any way to reuse/merge the code and then just pass the constant, kind of like a function in a programming language? I know TS is not a programming language, but I'm hoping this can be done - something like
> temp.myFunc($title) = TEXT
temp.myFunc {
    ...
$theTitle = $title
}
> marks.TEST1 < temp.myFunc({$title1})
marks.TEST2 < temp.myFunc({$title2})


there are no functions with parameters in typoscript
but you may use your own individual values for each usage

with
temp.something = <OBJECT>
you define a temporary object definition you may use afterwards.
maybe like:
page.10.20 < temp.something
then all your temp.something-definition is copied to this place.
you also may use it at a different place:
page.10.40 < temp.something
and both have nothing in common. It are copies and not references!

afterwards you can individualize it:
page.10.20.value = {$title1}
page.10.40.value = {$title2}

example:
temp.header = COA
temp.header {
    10 = TEXT
    10.value = default headline, which will be replaced afterwards
    10.wrap = <h1>|</h1>

    20 = TEXT
    20.data = date : d-m-y
    20.wrap = <span class="date">info from:|</span>
}

page.10.20 < temp.header
page.10.20.10.value = headline in Column left

page.10.40 < temp.header
page.10.40.10.value = headline in Column right

or (taking definitions of above in acount)
page.10.20 < temp.header
page.10.20.10.value = {$title1}
page.10.20.10.wrap = {$titleWrap1}

page.10.40 < temp.header
page.10.40.10.value = {$title2}
page.10.40.10.wrap = {$titleWrap2}

bernd
-- 
http://www.pi-phi.de/cheatsheet.html
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english


   


More information about the TYPO3-english mailing list