0
votes

I have a project which has it's all templates, css, layouts and images in the folder fileadmin/templates .

In my layouts I have multiple links to the images present in the fileadmin/images folder and it looks kinda complex to have all the links to be referred to fileadmin/images.

Example : 
src="fileadmin/images/dog.jpg"
src="fileadmin/images/cat.jpg"
src="fileadmin/images/monkey.jpg"

Instead of doing this can I assign a object in the typoscript (..in the template) like

page.10 = FLUIDTEMPLATE
page.10{
variables{
    paths.images=fileadmin/images
    paths.css=fileadmin/css
    paths.js=fileadmin/js
}
}

and access this from the HTML pages as

src="{paths.images}/cat.jgp"
src="{paths.js}/close.js"

I am using Typo3 version 6.0.4.

1
You could, but not with a dot in the variable name as this is reserved for array access. - pgampe
So I should declare 3 different variables for each path ? I was thinking if can declare an object called Path and its variables as image, css and js and assign values respectively .. Is that a possible solution ? If you can, can you please throw in some code here? Thanks - dora
TypoScript does not know about objects. TypoScriptis a nested PHP array that keys evaluated with some foreach loops and case statements. You could use names like pathImages, pathCss, pathJs. - pgampe
Oh.. okay. Thanks for the help :) Also, I had another doubt, Can I declare arrays here in TypoScript and use them in the FLUID templates ? - dora
No, TypoScript does not know arrays, but only strings. - pgampe

1 Answers

1
votes

You may use pathImages, pathCss and pathJs.

TypoScript does not know about arrays and there is no way to return an array via TypoScript. TypoScript is transformed into a PHP array by separation it at the dots and then it is rendered via multiple foreach loops. Only strings are returned as a result of this process.