[TYPO3-english] PAGE in COA_INT?

Stephan Schuler Stephan.Schuler at netlogix.de
Wed May 14 22:32:18 CEST 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hey Jacob.

There are some huge glitches that need to be discussed individually. So here we go.

The first thing is: I don't like your approach, at all. I'd rather use one single CSS file that gets used all over the place and appears equally on every single page. That makes everything feel a lot quicker. Let's say you have 4KB of CSS that need to be loaded per page. On every page, because they differ. Or you have about 20KB of CSS which overs every singe CSS you need. It's not about bandwidth, although the fifth click on your site makes one huge CSS file even save you bandwidth. But let's ignore that for a minute. Loading a 20KB file doesn't take any loger then downloading a 4KB file, because the one and only thing that matters is latency. Allowing the clients to skip every single CSS request completely (except the very first one, of course) makes your site feel a lot quicker.
So I would defintively skip both, inline CSS an splitted files but go for a single file that covers everything.

The next thing is the way you create your link inside of the link tag. That's pretty awefull. You skip TypoLink. So you skip cHashes, so you most likely skip caching on the server side. Use a regular TypoLink pointing to that page, add your type property and use "wrap" to create the link tag.

Instead of creating a dynamic link pointing to a PHP dynamic page creating CSS dynamically through a PHP process, I'd rather write CSS to a css file, put that to typo3temp and and return the target link. This avoids PHP processes just to create CSS.

To even improve that: I'd adjust the TSFE header data and put the target CSS file path right in there. This allows the internal CSS script merger to merge that dynamic CSS file, which brings us to the advantage of my first point: A single file instead of two different improves latency behavior.

And to the very last: I don't think it's TypoScript on the HTML page that creates cached behavior. There is one link to your dynamic CSS resource pointing to "index.php?1234&type=22" (if we are on page 1234 currently). The browser doesn't care if the link is created dynamicaly by the very PHP process or has been fetched from cache. As long as we stay on page 1234, the resource link will always point to "index.php?1234&type=22). Using a COA_INT here doesn't give you any advantage of non-cached dynamic rendering, the string being sent to the browser will remain the same. The one thing which needs to be rendered dynamically is the *response* of your type=22 configuration. You need to either call that CSS-creator script with no_cache parameter or add some other configuration that forces the CSS thing to no_cache.

Well .. but no_cache isn't a good idea, especially if it's used on every single page.

My suggestion is to always render static background things and use JavaScript on the cient side to decide randomly to adjust a the "class" attribute of your "body" node. Your static CSS output only needs to change whenever someone uploads a new file, but changing your static CSS more often is useless.

I would create a specific record type for that. Just a title for TYPO3 backend maintenance. a file relation property and enable fields. Having a record type for that allows you to store your background image data in a TYPO3 sysfolder instead of a file system folder. Now you can add a TCEmain trigger to clear caches automatically when someone changes such a record -- which is exactly the time to recalculate CSS.

Frontend behavior is plain simple: Add dynamic CSS "body.backgroound-image-$recordUid" that adds that background image to your FE output. Either a dynamic CSS file being written by a small PHP script or you can even use inline CSS, as long as inline is merged by scriptmerger, too. Ontop of that, you add a small (and again: dynamic) JavaScript that knows all available background-image-$recordUid values, randoms them and attaches one of them to the body tag.

Advantages:
* Your FE output can be cache, because it doesn't differ any longer just for a dynamic background image
* Our CSS file can be cached, because of the same reason
* You can attach some CDN for both, images and CSS files easily
* You can use the TYPO3 script merger to merge CSS data properly, which dramatically reduces the file size
* When adding just enableFields to the record type, your editors can simply enable and disable certain background images without the need of deleting some files and reuploading them just a couple of days later.

But to come back to your initial question: No, you cannot drop a PAGE in a COA_INT. That just doesn't work that way. But you don't need to, and the source of your problem is in a completely different section. It's not the HTML that gets cached but shouldn't but it's the CSS output. And you need to trigger the TSFE->noCache() mechanism t avoid that -- just in case you really want to ignore my thougts and go on with creating dynamic CSS in a completely different PHP process.

Regards,

Stephan Schuler
Web-Entwickler

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de



- -----------------------------
PRTG Network Monitor
Lernen Sie, wie Sie Ihr Netz einfach und effektiv überwachen können. Jetzt anmelden zum netlogix-Event am 27.05.2014:
Jetzt anmelden: http://it-training.netlogix.de/angebote/events/prtg-network-monitor

Citrix XenApp & Desktop 7.5 – Das Wichtigste in einem Tag
Lernen Sie die neue Version kennen. Jetzt anmelden zum netlogix 79er Seminar am 18.06.2014 für nur 79.- EUR:
Jetzt anmelden: http://it-training.netlogix.de/angebote/79ers/citrix-xendesktop-75
- ------------------------------------



- --
netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



________________________________________
Von: typo3-english-bounces at lists.typo3.org [typo3-english-bounces at lists.typo3.org]" im Auftrag von "Jacco van der Post [jacco at id-internetservices.com]
Gesendet: Mittwoch, 14. Mai 2014 17:03
An: typo3-english at lists.typo3.org
Betreff: [TYPO3-english]  PAGE in COA_INT?

Hi!

Is seems not possible to put a PAGE object in a COA_INT?

I am trying to create dynamic CSS for a random background image to get
rid of inline CSS. If I do this without COA_INT it works, but it gets
cached in the browser (unless hard refresh).

When putting the bgCss in a COA_INT it doesn't work.


#bgCss = COA_INT
#bgCss.10 = PAGE
#bgCss.10 {

bgCss = PAGE
bgCss {
     typeNum = 22
     config {
     additionalHeaders = Content-type: text/css
     disableAllHeaderCode = 1
     }
     stdWrap.required = 1
     stdWrap.wrap = |
     10 = TEXT
     10.value (
     body {
     )
     20 = IMG_RESOURCE
     20 {
         file.import.filelist  =
fileadmin/user_upload/Achtergrond_afbeeldingen/ | jpg,jpeg,gif,png |
name | | 1
         file.import.listNum = rand
         stdWrap.wrap = background-image: url('/|');}
     }
}

page.headerData.10 = COA_INT
page.headerData.10.10 = TEXT
page.headerData.10.10.dataWrap = <link rel="stylesheet" type="text/css"
href="index.php?id={field:uid}&type=22" />|

- --
Kind Regards

Jacco van der Post
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english

-----BEGIN PGP SIGNATURE-----
Version: PGP Universal 3.3.2 (Build 15238)
Charset: utf-8

wpUDBQFTc9LSpp0IwsibV8MBCD0iBACEsP7rGz+TomkN7FnlkqS09jIs55T9WmPH
U0Oiq5MZR7oU/NkoXWEI7Rd+Pk6O0n9OGMRxufxsjo1Tvv6/kCMUbn6vmhgTOB/k
+lz+p52OO0/XFFqOylZpGMCumo/AFO4Va6wlQeeQ8bQ8zUSdymcgegkubPocH9O4
/uQLJwhsng==
=9dVx
-----END PGP SIGNATURE-----


More information about the TYPO3-english mailing list