If you are an extension programmer and want to find out how to use certain parts of TemplaVoila or take influence on some processing in your own extensions, this is your part of the manual. This section requires PHP knowledge as well as some basic experience with extension programming in TYPO3.
Where it made sense, we have implemented some hooks every here and there in TemplaVoila in order to give extension programmers a chance to override or extend certain functionality. Just register your own function and you will take over the control or take influence on that part of TemplaVoila.
If you need to extend a certain part and don't find a way to include your own code, just get in touch with us, we might include some API to implement your own user defined function.
Generally, there are two ways of providing hooks, the ones using t3lib_div::getUserObj() and those using t3lib_div::callUserFunction(). Hooks going the getUserObj way require a class name while callUserFunction hooks accept a class name and method name. Here is an example of how to register your own function in both ways:
// The getUserObject way:
$TYPO3_CONF_VARS['EXTCONF']['templavoila'][ sub_key ][subsub_key][] = 'my_class';
// The callUserFunction way:
$TYPO3_CONF_VARS['EXTCONF']['templavoila'][ sub_key ][subsub_key][] = 'my_class->my_method';
Which type of hook was implemented, is specified in the column type in the reference below. It also states if only one or multiple userfunctions are allowed for that hook. In the latter case you'll have to add your class name (and method) to an array of userfunctions.
Hint: You should read the section about hooks in the TYPO3 core APIs document, which is available on TYPO3.org. And of course you should have a look at the source code where the hook is provided before you implement your own userfunction.
Sub key: | Sub-sub key: | Type: | Purpose / description: |
|---|---|---|---|
cm1 | eTypesConfGen | callUserFunction / single | “eTypes” are presets which are use in the click module (cm1) in order to create the field configuration of a data structure. While mapping you may choose between these eTypes, examples are “text”, “image”, “imagefixed”, “ce” and so on. The “input” eType for example, results in this configuration within the data structure: <TCEforms> <config> <type>input</type> <size>30</size> <eval>trim</eval> </config> <label>test</label> </TCEforms> If you want to override the creation of this configuration for a certain eType, you may use eTypesConfGenUserfunctions to specify your user defined function. Provide a user function for the eType “input”, you might specify something like this in your extension's page TSconfig: $TYPO3_CONF_VARS['EXTCONF']['templavoila']['cm1']['eTypesConfGen']['input'] = 'tx_myClass->myMethod' For more information on how to design your user function have a look at templavoila/cm1/index.php |
cm1 | eTypesExtraFormFields | callUserFunction / single | (Also see the explanation about eTypes above) Using this hook you may specify a user function which will render certain extra fields for certain eTypes in the mapping dialogues. One popular extra field is the object path for the TypoScriptObject eType. Example: $TYPO3_CONF_VARS['EXTCONF']['templavoila']['cm1']['eTypesExtraFormFields']['input'] = 'tx_myClass->myMethod'; |
mod1 | renderTopToolbar | callUserFunction / multiple | Use this hook if you want to output some HTML code at the very top of the Edit Page screen in the page module. This was hook was implemented for providing a custom toolbar related to the current page. Example: $TYPO3_CONF_VARS['EXTCONF']['templavoila']['mod1']['renderTopToolbar'][] = 'tx_myClass->myMethod'; |
mod1 | renderPreviewContent | getUserObj / multiple | Use this hook if you want to render the preview of a custom cType or override the default preview of a certain cType. This is great if you want to provide a preview for your own plugins! Let's say you wrote a plugin called myext_pi1. Just create a new function your tx_myext_pi1 class and register it in $TYPO3_CONF_VARS (see above). Your own function would look like this: Example: function renderPreviewContent_preProcess ($row, $table, &$alreadyRendered, &$reference) { if (row['CType'] == 'list' && $row['list_type'] == 'myext_pi1') { $content = '<strong>MyExt:</strong> '.htmlspecialchars('my custom preview'); $alreadyRendered = true; return $reference->linkEdit($content, $table, $row['uid']); } } |
mod1 | renderFrameworkClass | getUserObj / multiple | This function contains the following hook: renderFrameWork_preProcessOutput Called just before the final content is compiled for displaying the framework in the edit page screen. An example for using this hook is adding another icon into the title bar of certain content elements or the page. |
pi1 | renderElementClass | getUserObj / multiple | This function contains the following hook: renderElement_preProcessRow Gives you the chance to modify the row currently being rendered for frontend output. One way of using is, is selecting a different template object for a flexible content element, based on certain conditions. |
[TODO: Explain how other extensions can easily add new items to the sidebar]
if (t3lib_extMgm::isLoaded('templavoila')) {
require_once (t3lib_extMgm::extPath('templavoila').'mod1/class.tx_templavoila_mod1_sidebar.php');
}
class tx_myext_templavoila_sidebar {
function init() {
// Create / get instances:
$thisObj =& t3lib_div::getUserObj ('&tx_myext_templavoila_sidebar', '');
$sideBarObj =& t3lib_div::getUserObj ('&tx_templavoila_mod1_sidebar', '');
// Register sidebar item:
$sideBarObj->addItem ('tx_myext_templavoila_sidebar_item1', $thisObj, 'renderItem_myext', 'My Extension', 50);
}
function renderItem_myext(&$pObj) {
// Dummy output, just return the current page id:
return $pObj->id;
}
}
if (t3lib_extMgm::isLoaded('templavoila')) {
require_once (t3lib_extMgm::extPath($_EXTKEY).'class.tx_myext_templavoila_sidebar.php');
tx_myext_templavoila_sidebar::init();
}