[eluser]Random dude[/eluser]
I'm printing the setup code for http://tinymce.moxiecode.com/, which adds controls to the textarea form element.
It's a big jquery script with both " and ' quotes so just printing it from a codeigniter function is difficult, not to mention ugly.
Should I just put the jquery code in a php file and using php include to include it?
[eluser]osci[/eluser]
That is a solution but what about customizing to different projects, or even controllers?
I have a helper for tinymce and jquery onload, hope it helps
Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function jquery_on_load($scripts)
{
$str = '<$cript type="text/javascript">$(function(){';
$str .= $scripts;
$str .= '});</$cript>';
return $str;
}
function admin_tinymce($target_elem='textarea.tinymce',
$plugins='forecolor,|,bullist,numlist,|,outdent,indent,blockquote,|,sub,sup,|,charmap,hr,|,link,unlink,image,|,cut,copy,paste,pastetext,pasteword,|,undo,redo,|,cleanup,removeformat,code,|,visualaid,|,preview,|,fullscreen',
$toolbar1='forecolor,|,bullist,numlist,|,outdent,indent,blockquote,|,sub,sup,|,charmap,hr,|,link,unlink,image,|,cut,copy,paste,pastetext,pasteword,|,undo,redo,|,cleanup,removeformat,code,|,visualaid,|,preview,|,fullscreen',
$toolbar2='bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontsizeselect,|,tablecontrols',
$toolbar3='',
$external_list_url='lists/template_list.js',
$external_image_url='/filemanager/imagelist',
$external_link_url='/filemanager/filelist',
$external_media_url='lists/media_list.js',
$language_abbr='en')
{
$str = "$('".$target_elem."').tinymce({
script_url : '/ui/js/tinymce/tiny_mce.js',
theme:'advanced',
skin:'o2k7',
skin_variant:'black',
plugins:'".$plugins."',
theme_advanced_buttons1:'".$toolbar1."',
theme_advanced_buttons2:'".$toolbar2."',
theme_advanced_buttons3:'".$toolbar3."',
theme_advanced_toolbar_location: 'top',
theme_advanced_toolbar_align:'left',
theme_advanced_statusbar_location:'bottom',
theme_advanced_resizing:true,
template_external_list_url:'".$external_list_url."',
external_image_list_url:'".$external_image_url."',
external_link_list_url:'".$external_link_url."',
media_external_list_url:'".$external_media_url."',
entity_encoding:'raw',
translate_mode:true,
language:'$language_abbr',
relative_urls:false
});";
return $str;
}
Edit:
btw I don't remember the defaults and didn't check them right now. you should change
Code: $external_image_url='/filemanager/imagelist',
$external_link_url='/filemanager/filelist',
and ofcourse replace $script with script
|