Reputation: 31
I'm experiencing some trouble when including TinyMCE js files in my production environment.
The problem:
CakePHP Installation:
It's in a shared host and I've done the following to get it to work:
app, plugin, vendor and lib directories are one level up the public_html directory. (in my case /home2/username/)
the contents from webroot were copied into /home2/username/public_html
Finally I modified Cake's constant ROOT to match /home2/username/ in the copied index.php file from webroot.
As I said before the only thing I can think about is htaccess doing something when tinymce.min.js starts including other js files but I'm no expert in apache or rewrite rules. Everything else works perfectly.
Views:
The javascript files are included in admin_add and admin_edit views for articles using the html helper, they're not between head html tags.
<?php echo $this->Html->script('tinymce/tinymce.min'); ?>
<?php echo $this->Html->script('tinymce/init'); ?>
as an example my admin_add.ctp looks like this:
<?php echo $this->Html->script('tinymce/tinymce.min'); ?>
<?php echo $this->Html->script('tinymce/init'); ?>
<div class="articulo prev">
<?php echo $this->Form->create('Articulo'); ?>
<fieldset>
<legend><?php echo __('Crear Articulo'); ?></legend>
<?php
echo $this->Form->input('titulo');
echo $this->Form->input('contenido');
echo $this->Form->input('categoria_id', array('type' => 'select', 'options' => $categorias, 'label' => 'Categoria', 'empty' => 'Seleccionar'));
echo $this->Form->input('fecha');
echo $this->Form->input('usuario_id');
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="links_interes">
<title><?php echo __('Acciones'); ?></title>
<ul>
<li><?php echo $this->Html->link(__('Listar Articulos'), array('action' => 'index')); ?></li>
<li><?php echo $this->Html->link(__('Listar Usuarios'), array('controller' => 'usuarios', 'action' => 'index')); ?> </li>
<li><?php echo $this->Html->link(__('Crear Usuario'), array('controller' => 'usuarios', 'action' => 'add')); ?> </li>
</ul>
</div>
Upvotes: 0
Views: 410
Reputation: 31
After two days researching I found this: Why is the JavaScript file parsed as PHP in my Cake plugin?
I couldn't try any of the mentioned solutions in that post because of hosting restrictions, can't edit php.ini and php function symlink(); doesn't work so...
Added a rule to .htaccess so the directory remains unaffected by cake's rewrite rules:
RewriteRule ^_noUrlReWrite/(.*) _noUrlReWrite/$1 [L]
Finally chaged the script call to load with the full url
echo $this->Html->script('http://www.sitesdomain.com/_noUrlReWrite/js/tinymce/init.js');
And there was working, then came up another problem, tinymce's toolbar characters looked weird, like wrong encoding.
The problem was with firefox and is because: Firefox (which supports @font-face from v3.5) does not allow cross-domain fonts by default. This means the font must be served up from the same domain (and sub-domain) unless you can add an “Access-Control-Allow-Origin” header to the font.
Then I created another .htaccess in tinymce folder with:
<FilesMatch "\.(ttf|otf|eot|woff|tiff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
And problem solved!
Upvotes: 1