Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3 - geting images from a folder using Typoscript

I try to read pics (for a slider) from a folder. I have a marker called ###SLIDER### and my images are in the fileadmin/sliders/ folder.

I would like to achieve the following output as in the template that I bought:

       <div class="camera_wrap">
            <div data-src="fileadmin/sliders/slider_1.jpg">
                <div class="camera-caption fadeIn">Text_1</div>
            </div>
            <div data-src="fileadmin/sliders/slider_2.jpg">
                <div class="camera-caption fadeIn">Text_2</div>
            </div>
            <div data-src="fileadmin/sliders/slider_3.jpg">
                <div class="camera-caption fadeIn">Text_3</div>
            </div>
        </div>

How can I load the images from a folder using Typoscript and display it this way?

like image 310
Shao Khan Avatar asked Oct 16 '13 07:10

Shao Khan


1 Answers

The following code will give you what you want but without the captions. It works in TYPO3 4.5.x. I'm not sure that it works in higher versions as the description of filelist in the current (as of 16/10/2013) manual is somewhat confusing so I don't know if something has changed in the newer versions.

YOUR_MARKER = TEXT
YOUR_MARKER {
  filelist = fileadmin/sliders/
  split {
    token = ,
    cObjNum = 1
    1 {
      current = 1
      wrap = <div data-src="fileadmin/sliders/|"></div>
    }
  }
  wrap = <div class="camera_wrap">|</div>
}

NOTE: This is a very simple example that presumes that all the images in the folder are already resized to appropriate dimensions and that all the files within the folder are images. To make it better, the first (1) object of the split might be set to be IMG_RESOURCE. This way it would check that only images are outputted and it would allow you to use GIFBUILDER to resize the images if needed.

like image 190
tmt Avatar answered Oct 29 '22 15:10

tmt