Feature #24463
closed
Epic #55575: Streamline JavaScript Code in the TYPO3 Backend
Add Javascript-Files from CDN
Added by Anonymous almost 14 years ago.
Updated over 9 years ago.
Description
At this moment, there is no possibility to load Javascript-Files from the internet.
The PageRenderer will insert only local files:
$properties['file'] = t3lib_div::resolveBackPath($properties['file']);
$properties['file'] = t3lib_div::createVersionNumberedFilename($properties['file']);
So if I use the follow config in HOOK:
$params['jsLibs']['jQueryTOOLS'] = array(
'file' => 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js',
'section' => t3lib_PageRenderer::PART_HEADER,
'forceOnTop' => true,
);
The file will not be loaded, because it is not on the filesystem.
This should work for jsLibs and jsFile
Best regards
Jürgen
(issue imported from #M16903)
Please close this Issue.
After some trying, it seems to work fine.
Best regards
Jürgen
Jürgen, would be nice if you could explain, how you solved this issue (could help others..). In this case, please reopen!
You can use the external = 1 attribute to disable the file_exists() checks. At least in TypoScript it's available.
page.includeJS.jQuery = http://cdn.whatever
page.includeJS.jQuery.external = 1
I include the script by HOOK:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess']['jquery'] = "EXT:myext/class.tx_myclass.php:&tx_myext->addJqByHook";
The Methode looks like this:
class tx_myext {
function addJqByHook($params) {
$params['jsLibs']['jQuery'] = array(
'file' => 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js',
'section' => t3lib_PageRenderer::PART_HEADER,
'forceOnTop' => true,
);
}
}
This will work in Typo3 4.3.x and newer
Um... It's really bad that it seems not to be possible to set "external" attribute using PHP API.
However for your case, I would recommend you to add it using TypoScript
Sorry, seems to be a misunderstanding, the methode above works.
I had the feeling it does not work, so I reported it as a bug.
So in first place the bug report of mine was the bug ;)
Yes, but it's a bad method ;-)
We have an API for that t3lib_pageRenderer::addJsFile(), however this is not able to cope with the "external" flag.
Yea, I know
But I have to use it, because I cant use the pageRenderer in This way.
When I set the Script, the pagerenderer isnt set to $GLOBALS.
The EXT I use there is t3jquery, hard thing ;)
- Target version deleted (
0)
- Parent task set to #55575
- Status changed from Accepted to Needs Feedback
Hey Jürgen,
could we close this one now?
Yes, close it, I stopped developping for TYPO3, so I do not need this anymore
- Status changed from Needs Feedback to Closed
Also available in: Atom
PDF