[TYPO3-mvc] How to use jQuery in BE Module?
Sebastian Schreiber
me at schreibersebastian.de
Thu Feb 9 16:12:10 CET 2012
Write a viewHelper like the following one:
class Tx_MyExt_ViewHelpers_Be_AddJsFileRelativeToExtensionViewHelper
extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
/**
*
* @param string $extensionKey
* @param string $pathToJsFile
* @return void
*/
public function render($extensionKey = NULL, $pathToJsFile = NULL) {
if (NULL === $pathToJsFile) {
$pathToJsFile = $this->renderChildren();
}
if (NULL === $extensionKey) {
$extensionKey =
t3lib_div::camelCaseToLowerCaseUnderscored($this->controllerContext->getRequest()->getControllerExtensionName());
}
// Remove the preceding /
$pathToJsFile = ltrim($pathToJsFile, '/');
$relativePath = t3lib_extMgm::extRelPath($extensionKey, TRUE);
$pageRenderer = $this->getDocInstance()->getPageRenderer();
/* @var $pageRenderer t3lib_PageRenderer */
$pageRenderer->addJsFile($relativePath . $pathToJsFile);
}
}
Then call it your fluid-template with your extension key and the
relative path from your extension.
Am 09.02.2012 15:55, schrieb Alexander Dick:
> Am 09.02.2012 15:52, schrieb Alexander Dick:
>> <script tpye=
>
> should be
>
> <script type=
>
> of course, small typo here ;-)
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
--
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)
Schanzenstraße 27, Schlosserei 4
D-51063 Köln
T 0221 677 88 541
M 0176 431 05 790
Skype schreibersebastian.de
me at schreibersebastian.de
www.schreibersebastian.de
Steuernummer: 217 / 5269 / 4675
More information about the TYPO3-project-typo3v4mvc
mailing list