Sunday, February 17, 2013

Using an Extbase extension in Typoscript

Using typoscript to insert or configure an Extbase extension is quite easy. I use the following typoscript code to assign an Extbase extension to a typoscript object.


myObject = USER
myObject {
     userFunc = tx_extbase_core_bootstrap->run
     extensionName = YourExtensionName
     pluginName = YourPluginName
     switchableControllerActions {
       YourControllerName {
         1 = youraction
       }
     }
     settings =< plugin.tx_yourextensionname.settings
     persistence =< plugin.tx_yourextensionname.persistence
     view =< plugin.tx_yourextensionname.view
}

The first thing to notice is, that the name of your Extension must be in UpperCamelCase. so if your extension key is "your_extension_name", then you have to set it to "YourExtensionName". This also applies to the plugin name.

The next thing you have to do is to configure the section switchableControllerActions with the controller- and the action-name you wish to use.

Last but not least you should assign the settings, the persistence- and the view-configuration to the typoscript object. Now you`re ready to use your Extbase extension in typoscript.

Notice in the example above, that the extension`s typoscript settings are imported to the new typoscript object. With this, you can modify the settings for the typoscript object individually. The same applies to the persistence- and the view-configuration. With this, you are very flexible using your Extbase extension in typoscript.