[TYPO3-dev] ExtJs in the TYPO3 BE how-to questions?

Steffen Kamper info at sk-typo3.de
Tue Feb 22 11:57:46 CET 2011


Hi Francois,

Am 22.02.2011 11:39, schrieb François Suter:
> Hi all,
>
> I have a few questions regarding proper usage of ExtJS-based scripts in
> the TYPO3 BE:
>

fine - also good for all others to know what the best practise is.


> 1) I know some mechanism was defined to store localized string read from
> locallang files. How is this done properly?
>

1)
pagerenderer has a method to include a language file for javascript. 
This is simular to the inclusion via LANG you do for php.
Example:
$this->pageRenderer->addInlineLanguageLabelFile(t3lib_extMgm::extPath('em', 
'language/locallang.xml'));

2)
If you have some single labels to include, just define an array with 
these labels like
$labels['yes'] = 
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
		$labels['no'] = 
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
$this->pageRenderer->addInlineLanguageLabelArray($labels);

You can do that additional to step 1.



> 2) about MessageBoxes: is it ok to simple call Ext.MessageBox.show() or
> do we have a specific type of MessageBoxes for TYPO3 extending the
> original one?
>

it's ok to do so, but we already have a file you should include:
t3lib(js/extjs/notifications.js

There you find some predefined message boxes and windows for easy usage, eg
TYPO3.Dialog.InformationDialog(config)
TYPO3.Dialog.QuestionDialog(config)
a.s.o.

But it's not mandantory to use these. In same file we have windows that 
have already the css classes for TYPO3, so that makes life bit easier.


> 3) about buttons in MessageBoxes: same question, do we have specific
> classes in TYPO3 for buttons? Additional question: if I want my button
> label to be translatable, I guess I have to define my own custom button
> and not use something like Ext.MessageBox.OK, right?
>

see above. ExtJs comes with translations for exact these labels, and 
they are included automatically by pagerenderer

> 4) about name-spacing, what should really go into it and what is ok to
> just stuff inside an Ext.onReady() call?
>

namespace is important to be independent from other scripts, so no 
problems if your function have same name.
We take the TYPO3 prefix always to indicate that we are inside TYPO3.
The BE already use some namespaces, best is to open BE and console and 
type "top.TYPO3" - press ctrl + return to execute. You'll find the TYPO3 
object in console and can browse it to see all existing components.

For extensions i suggest namespace
TYPO3.[extkey].[classname]
So you are save that the namespace is already given.

Hope your questions are answered now.

vg Steffen




More information about the TYPO3-dev mailing list