Project

General

Profile

Actions

Task #48383

closed

Epic #55575: Streamline JavaScript Code in the TYPO3 Backend

RequireJS does not consider correct namespace prefix

Added by Oliver Hader almost 11 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Miscellaneous
Target version:
Start date:
2013-05-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.1
PHP Version:
5.3
Tags:
Complexity:
hard
Sprint Focus:

Description

My extension "mapping" uses these namespace prefixes in PHP "OliverHader\Mapping" (vendor, package).
However, the requireJS implementation in the PageRenderer ignores that and adds "TYPO3\CMS" as prefix.

The behaviour shall be the same as for PHP class files - the "\TYPO3\CMS" prefix is a special case for the Core only.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Feature #55264: requireJS for frontend in PageRenderer and TypoScriptRejected2014-01-23

Actions
Actions #1

Updated by Daniel Siepmann about 10 years ago

  • Parent task set to #55575
  • Is Regression set to No

`

Actions #2

Updated by Daniel Siepmann about 10 years ago

The only thing I can implement at the moment is to remove the TYPO3 vender for external extensions. But I don't have any clue how to add the vendor for JS Files as it just exists inside PHP Files.

IF someone has an idea code it, or answer, so I can get into it.

Actions #3

Updated by Benni Mack over 8 years ago

  • Assignee set to Benni Mack
  • Target version set to 7.4 (Backend)
  • Sprint Focus set to Stabilization Sprint
Actions #4

Updated by Mathias Brodala over 8 years ago

You can manually add your prefix with the PageRenderer hook render-preProcess like this:

$pageRenderer->addRequireJsConfiguration([
  'paths' => [
    'Vendor/Package' => PathUtility::getRelativePath(PATH_typo3, GeneralUtility::getFileAbsFileName('EXT:package/Resources/Public/JavaScript/')),
  ],
]);
Actions #5

Updated by Markus Klein over 8 years ago

  • Status changed from New to Rejected
  • Assignee deleted (Benni Mack)
  • Target version deleted (7.4 (Backend))
  • Complexity changed from medium to hard
  • Sprint Focus deleted (Stabilization Sprint)

This is still private API of Core. To add you own modules you need to do it like this:

$fullJsPath = 'EXT:' . $this->extKey . '/Resources/Public/JavaScript/';
$fullJsPath = GeneralUtility::getFileAbsFileName($fullJsPath);
$fullJsPath = PathUtility::getRelativePath(PATH_site, $fullJsPath);
$fullJsPath = $tsfe->absRefPrefix . rtrim($fullJsPath, '/');

$pageRenderer->addRequireJsConfiguration([
    'paths' => [
        'Reelworx/MyExt' => $fullJsPath
    ]
]);

$pageRenderer->loadRequireJsModule('Reelworx/MyExt/somemodule');

Making this API really versatile is a load of work and for sure no bug!

Actions #6

Updated by Benni Mack over 8 years ago

  • Tracker changed from Bug to Task
  • Status changed from Rejected to Accepted
  • Target version set to 7.5

ok. but we should "do it right" for 7.5 then.

Actions #7

Updated by Benni Mack over 8 years ago

  • Assignee set to Benni Mack
  • Target version changed from 7.5 to 7 LTS
Actions #8

Updated by Frank Nägler over 8 years ago

@Benni Mack I think the solution from Markus is a good example how to do it.
I think we need no change here, the default namespace is TYPO3\CMS\EXTKEY... If I need or want another prefix, I can register my own.
We don't know the VENDOR prefix, I have no idea how to resolve this VENDOR automatic.

Actions #9

Updated by Benni Mack over 8 years ago

  • Status changed from Accepted to Closed

Is fine for now, I think that's actually quite OK.

Actions

Also available in: Atom PDF