[TYPO3-dev] Fight the no_cache parameter

JoH asenau info at cybercraft.de
Tue Apr 17 12:01:19 CEST 2007


>> This all can be done within one single USER element containing a COA
>> or a CASE with USER and USER_INT as subelements.
>
> This is very interesting approach. Have you tested is successfully?
>
> If yes, can you provide simple pure PHP example? E.g. using two
> methods - cached and not-cached based on something and main function
> showing how to call them?

What do you mean by "pure PHP example"?
If you really like it, you can of course create the parameter arrays for the
smaller chunks manually inside a PHP file, but I don't see I reason why one
should do it.

Anyway here's a small example:

function main($content,$conf) {
$user_conf = array();
$user_conf['userFunc'] = 'classname->cachedElementFunction';
$cachedElement = $this->cObj->cObjGetSingle('USER',$user_conf);

$user_int_conf = array();
$user_int_conf['userFunc'] = 'classname->nonCachedElementFunction';
$nonCachedElement = $this->cObj->cObjGetSingle('USER_INT',$user_int_conf);


$content = $cachedElement.chr(10).$nonCachedElement;

return $content;
}

function cachedElementFunction($content,$conf) {
return 'This is a cached time: '.date('c');
}

function nonCachedElementFunction($content,$conf) {
return 'This is a non cached time: '.date('c');
}

If you use $this->cObj->cObjGetSingle this will take over the switch between
cached and non cached content.
You can trigger the non cached content with USER_INT or COA_INT.
Since this is still kind of "TypoScript" I don't get it, why one would want
to do it using pure PHP.

Another drawback for the pure PHP approach is, that the user of this plugin
is forced to accept the cache settings of the different parts, while the
TypoScript approach would give him the option to change this behaviour and
even add completely different setup, additional wraps and other useful
stuff.

IMHO a TYPO3 extension that is offering a plugin or a new content element
should always contain an appropriate TypoScript setup and never be based on
pure PHP.

Just my 2 non cached cents

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
openBC/Xing: http://www.cybercraft.de
T3 cookbook: http://www.typo3experts.com






More information about the TYPO3-dev mailing list