[TYPO3-dev] Fight the no_cache parameter

JoH asenau info at cybercraft.de
Mon Apr 16 11:46:03 CEST 2007


> I think we should keep it extremely simple for developers.
>
> Let's say we want to develop search extension.
>
> There are two cases:
>
> 1) Displaying the search form - the complete page should be cached.
>
> 2) Displaying the search results - extension output shouldn't be
> cached, all other things on page should be cached.
>
> Usually developers would make ext USER and use set_no_cache() for
> case 2, making all other things on page not cached without actual
> need.
>
> Instead, we should force USER_INT and extend it somehow to have
> special case - to cache it when neccessary:
> $cache_me = (is_there_search_query) ? FALSE : TRUE;
>
> We need something that simple.

Well it's not that simple, since the search result should never be cached.
In fact it shouldn't even get rendered if there's no search query.
So you should use two TypoScript elements in this case:

1. Search form USER
2. Search results USER_INT

If there's a search parameter in the URL the search results will be
rendered:

plugin.blah = USER
plugin.blah {
    userFunc = mainFunc
    renderObj = COA
    renderObj {
        10 = USER
        10.userFunc = searchformFunc
        20 = USER_INT
        20.userFunc = searchresultFunc
    }
}

checking is done in the mainFunc :

mainFunc($content,$conf) {

    /* if there's no searchparam we don't need element 20 at all */
    if(!t3lib_div::_GP('searchparam')) {
        unset($conf['renderObj.']['20']);
        unset($conf['renderObj.']['20.']);
    }
    /* rendering the COA with or without the USER_INT */
    $content =
$this->cObj->cObjGetSingle($conf['renderObj'],$conf['renderObj.'],);
    return $content;
}

Even if you don't like TypoScript and prefer doing things in PHP, this
simple switch could be helpful, since you don't have to use a TypoScript
Setup for the rest of the rendering functions.

HTH

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