[TYPO3-english] TS Code Reuse
Scotty C
superscotty19 at yahoo.com
Tue Apr 7 05:19:06 CEST 2015
Bernd,
I've applied your techniques (I think correctly?) and I'm getting a blank page. Here's what I have, paraphrased - note that I need to replace a weird parameter, that is, $path:
temp.Gallery = TEXTtemp.Gallery { wrap = <div class="gallery">|</div>
filelist = {$path}||name||0
split { token = , cObjNum = 1 1 { current = 1 wrap = | filelink {
path = {$path}
icon = 1
icon_image_ext_list = pdf,png,gif,jpg iconCObject = IMAGE iconCObject { makeThumbs = 1 file {
import = {$path}
import.current = 1 } # end file wrap = | } # end CObject } # end filelink } # end 1 } # end split} # end temp.kataloge
page.19 = TEMPLATE page.19 { template = FILE template.file = fileadmin/test/template.html workOnSubpart = DOCUMENT
marks.GALLERY < temp.Gallerymarks.GALLERY.filelist = fileadmin/galleries/gallery1/||name||0marks.GALLERY.split.1.filelink.path = fileadmin/galleries/gallery1/marks.GALLERY.split.1.filelink.iconCObject.file.import = fileadmin/galleries/gallery1/
marks.GALLERY.append < temp.Gallerymarks.GALLERY.filelist = fileadmin/galleries/gallery2/||name||0marks.GALLERY.split.1.filelink.path = fileadmin/galleries/gallery2/marks.GALLERY.split.1.filelink.iconCObject.file.import = fileadmin/galleries/gallery2/
}
Thanks as always,-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