Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SOLVED: TinyMCE problem - Javascript attempting to load .php file


Go to End


5 Posts   5686 Views

Avatar
jonathanc

Community Member, 1 Post

19 February 2014 at 11:22am

Edited: 19/02/2014 11:45am

Hi there,

New to SilverStripe and new to the forums.

I just installed a fresh version of Silverstripe on top of Ubuntu/Nginx/PHP/Mysql and so far everything has worked perfectly except for the following:

When I go to load the page editor, the page fails to load the TinyMCE Editor and inspector shows the error:

Uncaught SyntaxError: Unexpected token < 

Essentially....

At the bottom of the page in the Javascript Includes area, there is an include attempting to load a .php file instead of a .js file and of course fails when the first line is "<?php"

<script type="text/javascript" src="/framework/thirdparty/tinymce/tiny_mce_gzip.php?m=1384281859&amp;js=1&amp;plugins=table,emotions,paste,media,fullscreen,inlinepopups,advimagescale&amp;themes=advanced&amp;languages=en&amp;diskcache=true&amp;src=false"></script>

Is this a failure on something else, or is there somewhere I can change it to load the .js file instead of the .php file.

Thanks!

------------------

Found a solution:

Under /framework/forms/HtmlEditorField.php i replaced the following block of code:

if(Config::inst()->get('HtmlEditorField', 'use_gzip')) {
                        $internalPlugins = array();
                        foreach($configObj->getPlugins() as $plugin => $path) if(!$path) $internalPlugins[] = $plugin;
                        $tag = TinyMCE_Compressor::renderTag(array(
                                'url' => THIRDPARTY_DIR . '/tinymce/tiny_mce_gzip.js',
                                'plugins' => implode(',', $internalPlugins),
                                'themes' => 'advanced',
                                'languages' => $configObj->getOption('language')
                        ), true);
                        preg_match('/src="([^"]*)"/', $tag, $matches);
                        Requirements::javascript(html_entity_decode($matches[1]));
 
                } else {
                        Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
                }

with

Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');

Avatar
neilcreagh

Community Member, 136 Posts

18 June 2015 at 3:17am

Thanks! I just had this same issue.
(Never had this issue before but am also using a shared hosting provider I've never used before)

Avatar
BalazsB

Community Member, 3 Posts

29 July 2015 at 11:57pm

Edited: 30/07/2015 2:27am

I've had the same issue and I'm pretty sure it's an NGINX configuration issue, but since I'm not the best at adjusting NGINX config files I've come up with the following solution.

Instead of messing with the core Silverstripe files (by modifying /framework/forms/HtmlEditorField.php) like jonathanc suggested, it's enough to add the line below to /mysite/_config.php:

In Silverstripe 3.0:

HTMLEditorField::$use_gzip = false;

In Silverstripe 3.1+:

Config::inst()->update('HtmlEditorField', 'use_gzip', false);

Avatar
Pyromanik

Community Member, 419 Posts

30 July 2015 at 3:46am

The proper way to do that in 3.1+ is via yml (although _config.php still works fine - I'm just sharing a different approach).
eg. mysite/_config/config.yml
add:

HTMLEditorField:
  use_gzip: false

Avatar
justin_t_brown

Community Member, 22 Posts

28 July 2017 at 6:00am

For some reason this fixed my problem with tinyMCE's css files not loading properly. It was a sudden and unexpected break. The only thing that changed on my system is my MacOS updated to 10.12.6, though looking through it's changelogs I have no idea why that would be the reason for the error. Oh well. Thanks!