[TYPO3-dev] Writing to page type <> 0

JoH asenau info at cybercraft.de
Sat Feb 17 14:51:07 CET 2007


>> Christian Lerrahn (Cerebrum) wrote:
>>> I think I've asked this question before but I'm not sure that I've
>>> ever good a useful reply. Is there any proper documentation of the
>>> TYPO3 page type concept? How do I make my extension write to a
>>> certain page type? E.g. if I wanted my extension to write to 99 in
>>> plain text, how would I do that? Any hints and pointers would be
>>> very much appreciated!
>>
>> myPage = PAGE
>> myPage.typeNum = 99
>> myPage.10 < plugins.tx_myext_pi1
>>
>> Do you mean this?
>>
>> However, this is probably a question better asked in the english main
>> mailinglist.
>
> If this is it, it probably is. However, I need to know more than this
> if I want to use it. How can the plugin react to the typeNum if it is
> only defined like this? It will not know what kind of context it is
> run in. That is what has always been (and remains) a mystery to me.
> E.g. if I wanted a plugin to write a different kind of output on
> typeNum=99 that typeNum=0, how would I do this. That's the reason why
> I ask the question here. I know how the TS works but how does it work
> in the plugin? I just haven't been able to disentangle the whole
> concept at all.

You can do this using TypoScript, since exactly this is the reason why
someone invented it: Configuring TYPO3 and it's extensions to do different
stuff in different situations.

myDefaultPage = PAGE
myDefaultPage.10 < plugins.tx_myext_pi1
myDefaultPage.10 {
    myTrigger = doThis
}

mySpecialPage = PAGE
mySpecialPage.typeNum = 99
mySpecialPage.10 < plugins.tx_myext_pi1
mySpecialPage.10 {
    myTrigger = doThat
}

In your plugin you will always get $content and $conf.
$conf is the array containing all the TypoScript stuff.

So in this case you could make a switch in PHP checking for the value of the
key myTrigger:

switch($conf['myTrigger']) {
    case 'doThis':
        $content = $this->doThis();
    break;
    case 'doThat':
        $content = $this->doThat();
    break;
    default:
        // Do nothing
}

So it's nmot up to your extension to "decide" in which context it is
"executed", its up to the TypoScript that is used to control your extension.

Reason: Somebody might use your extension for the same stuff but in another
context, and he might be using type 123 instead of 99. In this case your
approach won't work, while the TS approach does.

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