[TYPO3] Random CSS at every pageview
Edwin Blokker
a.stoutjesdijk at chello.nl
Sat Feb 16 13:08:27 CET 2008
Thanks a lot Dmitry,
I don't know PHP, but I just tried that out just by making the php file,
the css folder with css files, and copying the TS. It resulted in a
blank or "page being generated" page in the FE.
Regards,
Edwin.
Dmitry Dulepov [typo3] schreef:
> Edwin Blokker wrote:
>> Hi Benjamin,
>>
>> Thanks, but that's not what I want to do. I want to load a random CSS
>> file on every FE pageview, without the user doing anything.
>>
>> Does anyone have any suggestions?
>
> If you know PHP, you can do it this way:
>
> includeLibs.user_randomCSS = fileadmin/randomcss.php
> page.10.headerData = USER_INT
> page.10.headerData.userFunc = user_randomCSS
>
> And in randomCSS.php:
>
> <?php
> function user_randomCSS() {
> $cssfiles = array();
> $cssdir = 'fileadmin/mycssfiles';
> $dir = opendir(PATH_site . $cssdir); while (false != ($f =
> readdir($dir))) {
> if (preg_match('/\.css$', $f)) {
> $cssfiles[] = $f;
> }
> }
> closedir($dir);
> return '<link rel="stylesheet" type="text/css"
> href="fileadmin/mycssfiles/' .
> $cssfiles[rand(0, count($cssfiles) - 1] . '" />';
> }
> ?>
>
>
> Totally untested :)
>
More information about the TYPO3-english
mailing list