Feature #24463

Epic #55575: Streamline JavaScript Code in the TYPO3 Backend

Add Javascript-Files from CDN

Added by Anonymous over 4 years ago. Updated 4 months ago.

Status:Closed Start date:2011-01-03
Priority:Should have Due date:
Assigned To:Steffen Gebert % Done:

0%

Category:- Spent time: -
Target version:-
PHP Version: Sprint Focus:
Complexity:

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)

History

#1 Updated by Anonymous over 4 years ago

Please close this Issue.
After some trying, it seems to work fine.

Best regards
Jürgen

#2 Updated by Steffen Gebert over 4 years ago

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

#3 Updated by Anonymous over 4 years ago

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

#4 Updated by Steffen Gebert over 4 years ago

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

#5 Updated by Anonymous over 4 years ago

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 ;)

#6 Updated by Steffen Gebert over 4 years ago

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.

#7 Updated by Anonymous over 4 years ago

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 ;)

#8 Updated by Daniel Siepmann over 1 year ago

  • Target version deleted (0)
  • Parent task set to #55575

#9 Updated by Benjamin Mack 7 months ago

  • Status changed from Accepted to Needs Feedback

Hey Jürgen,

could we close this one now?

#10 Updated by Anonymous 7 months ago

Yes, close it, I stopped developping for TYPO3, so I do not need this anymore

#11 Updated by Benjamin Mack 4 months ago

  • Status changed from Needs Feedback to Closed

Also available in: Atom PDF