Reputation: 1702
I'm trying to create a simple CMS with CodeIgniter. I decided to work with Tinymce for the text area's but i got some problems implementing it.
This is how it tried to set it up:
folder structure:
- public
-- css
-- js
-- images
- system
-- <all CI folders here>
I wrote this helper to point to the public folder:
function asset_url(){
return base_url().'public/';
}
The tinymce init file:
<script src="<?=base_url()?>scripts/tiny_mce/tiny_mce.js" type="text/javascript">
tinyMCE.init({
theme : "advanced",
mode : "textareas",
plugins : "imagemanager,filemanager,insertdatetime,preview,emotions,visualchars,nonbreaking",
theme_advanced_buttons1_add: 'insertimage,insertfile',
theme_advanced_buttons2_add: 'separator,forecolor,backcolor',
theme_advanced_buttons3_add: 'emotions,insertdate,inserttime,preview,visualchars,nonbreaking',
theme_advanced_disable: "styleselect,formatselect,removeformat",
plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S",
theme_advanced_toolbar_align : "left",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true,
apply_source_formatting : true,
spellchecker_languages : "+English=en",
extended_valid_elements :"img[src|border=0|alt|title|width|height|align|name],"
+"a[href|target|name|title],"
+"p,"
invalid_elements: "table,span,tr,td,tbody,font"
});
</script>
This is my view:
<html>
<head>
<script type="text/javascript" src='<?php echo asset_url()."js/tiny_mce/tiny_mce.js" ?>'></script>
<script type="text/javascript" src='<?php echo asset_url()."js/tiny_mce/tinymce_properties.js" ?>'></script>
</head>
<body>
<form method="post" action="somepage">
<textarea name="content" style="width:100%">
</textarea>
</form>
</body>
</html>
So right now it just shows an empty normal textarea instead of the tinymce editor. The JS files are getting loaded, no errors there.
hopefully someone can give me a clue!
Upvotes: 0
Views: 1937
Reputation: 120
TinyMce has two packages the first is jquery independent while the other is jquery dependent. For the TinyMCe Jquery dependent package you need to include jquery before including the tinymce to the script like so.
<html>
<head>
<script type="text/javascript" src="<path to jquery>/jquery.js"></script>
<script type="text/javascript" src="<path to tinymce>/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector:"#myTextArea"
});
</script>
</head>
<body>
<form name="">
<textarea id="myTextArea"></textarea>
</form>
</body>
</html>
Upvotes: 1
Reputation: 7987
just edit your tinymce if u want tinymce in specific or any where else and i think this is the best idea for your problem ..
tinyMCE.init({
...
mode : "specific_textareas",
editor_selector : "mceEditor"
});
<textarea id="myarea1" class="mceEditor">This will be an editor.</textarea>
<textarea id="myarea2">This will NOT be an editor.</textarea>
Upvotes: 2