FCK Editor JavaScript Help

  • MasterZ
  • Expert
  • Expert
  • User avatar
  • Joined: Dec 04, 2004
  • Posts: 699
  • Loc: Colorado Springs
  • Status: Offline

Post September 10th, 2008, 3:17 am

Hey guys,

I wouldn't normally ask this but I'm down to my last week on a project and I have one last thing to do, other than bug fixes.. It deals with JavaScript and, sadly, I don't have a lot of experience with that.

I'm working on trying to do this but help would be greatly appreciated. I'm using the FCKEditor (a WYSIWYG editor). I need to insert a pre-formatted link into the box. I found all of the JavaScript functions that need to be run but I can't figure out how to put it all together.

I need
* links that when clicked will run a javascript function
* The function needs to run the command: oEditor.InsertHtml(HTML); and var oEditor = FCKeditorAPI.GetInstance('InstanceName') ;
* Information on the function is here: http://docs.fckeditor.net/FCKeditor_2.x ... ge_Samples
* Lastly, each link inserts different HTML.

If you guys could help me out in any way at all, I would really be grateful.
Image Eternal Truth Ministry - Biblical Resources, Forums
Have mercy on me, O God, according to your unfailing love; according to your great compassion blot out my transgressions. - Psalm 51:1 http://www.zssites.net - ZS Sites Web Hosting
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 10th, 2008, 3:17 am

  • kitcorsa
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 05, 2007
  • Posts: 122
  • Status: Offline

Post September 10th, 2008, 4:43 am

there are full installation instruction for fck editor with the download.

its simple, i never used it before but had it fully running in about 15 mins after reading the instructions.

on you admin/edit page have the following at the top in the java section

Code: [ Select ]
    <script type="text/javascript" src="fckeditor/fckeditor.js"></script>

    <script type="text/javascript">
    window.onload = function()
    {
    var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
    oFCKeditor.BasePath = "fckeditor/" ;
    oFCKeditor.Height = 600;
    oFCKeditor.ReplaceTextarea() ;
    }
</script>
  1.     <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
  2.     <script type="text/javascript">
  3.     window.onload = function()
  4.     {
  5.     var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
  6.     oFCKeditor.BasePath = "fckeditor/" ;
  7.     oFCKeditor.Height = 600;
  8.     oFCKeditor.ReplaceTextarea() ;
  9.     }
  10. </script>


obviously change the path to you FCK editor folder and script

Then in the body have the following

Code: [ Select ]
    <?php include_once("fckeditor/fckeditor.php") ; ?>


again change the path to your own

then where you want the editor to appear have the following.

Code: [ Select ]
        <textarea id="MyTextarea" name="content" >
        <? $fn = $_GET['p']; print htmlspecialchars(implode("",file($fn))); ?>
        </textarea><br>
        <input type="submit" value="Change!">
  1.         <textarea id="MyTextarea" name="content" >
  2.         <? $fn = $_GET['p']; print htmlspecialchars(implode("",file($fn))); ?>
  3.         </textarea><br>
  4.         <input type="submit" value="Change!">


P being the information you want to edit ie info from database or txt/php file etc
  • MasterZ
  • Expert
  • Expert
  • User avatar
  • Joined: Dec 04, 2004
  • Posts: 699
  • Loc: Colorado Springs
  • Status: Offline

Post September 10th, 2008, 5:12 am

Sorry for any confusion,

I have the editor itself working fine, I just need to make another link on the website that when clicked will insert a bit of html into the editor.
Image Eternal Truth Ministry - Biblical Resources, Forums
Have mercy on me, O God, according to your unfailing love; according to your great compassion blot out my transgressions. - Psalm 51:1 http://www.zssites.net - ZS Sites Web Hosting
  • kitcorsa
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 05, 2007
  • Posts: 122
  • Status: Offline

Post September 10th, 2008, 5:59 am

oh right, then you need to change this section of the code where the FCK editor is.

Code: [ Select ]
<textarea id="MyTextarea" name="content" >
<? $fn = $_GET['p']; print htmlspecialchars(implode("",file($fn))); ?>
</textarea><br>
<input type="submit" value="Change!">
  1. <textarea id="MyTextarea" name="content" >
  2. <? $fn = $_GET['p']; print htmlspecialchars(implode("",file($fn))); ?>
  3. </textarea><br>
  4. <input type="submit" value="Change!">


where is says $fn = $_get['p'] the P is the html you want to change. so you could put $fn = './text/text.txt' or you can change P to comething like $fn = $_get['usertext'] and define the usertext in the URL or somewhere on the page.
  • MasterZ
  • Expert
  • Expert
  • User avatar
  • Joined: Dec 04, 2004
  • Posts: 699
  • Loc: Colorado Springs
  • Status: Offline

Post September 10th, 2008, 3:09 pm

oEditor.InsertHtml(HTML) is a function that will insert a certain HTML statement into the editor, so I need a link that when clicked will call that function with an HTML statement assigned to that link, not reload the entire page.

What I'm trying to do is on the website that displays the fckeditor box, I'm trying to list all the documents that were uploaded on another page, and when you click on the document name it inserts an html link into the fckeditor that points to that document.
Image Eternal Truth Ministry - Biblical Resources, Forums
Have mercy on me, O God, according to your unfailing love; according to your great compassion blot out my transgressions. - Psalm 51:1 http://www.zssites.net - ZS Sites Web Hosting
  • kitcorsa
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 05, 2007
  • Posts: 122
  • Status: Offline

Post September 11th, 2008, 2:03 am

you trying to eddit a hlml file or a txt file or an inc file??
  • MasterZ
  • Expert
  • Expert
  • User avatar
  • Joined: Dec 04, 2004
  • Posts: 699
  • Loc: Colorado Springs
  • Status: Offline

Post September 11th, 2008, 3:53 am

I'm trying to figure out how to have a link use this command: oEditor.InsertHtml(HTML); as outlined in this page: http://docs.fckeditor.net/FCKeditor_2.x ... ge_Samples

# InsertHtml( html ) - inserts HTML in the current cursor position in the WYSIWYG editor textarea box.

I think just using an 'onClick' command for the link will do it but I will not get a chance to try it out until tonight.
Image Eternal Truth Ministry - Biblical Resources, Forums
Have mercy on me, O God, according to your unfailing love; according to your great compassion blot out my transgressions. - Psalm 51:1 http://www.zssites.net - ZS Sites Web Hosting
  • MasterZ
  • Expert
  • Expert
  • User avatar
  • Joined: Dec 04, 2004
  • Posts: 699
  • Loc: Colorado Springs
  • Status: Offline

Post September 12th, 2008, 4:40 pm

I have been trying to get this to work but I just can't :(

here is the code I am trying:

Code: [ Select ]
    <script language="JavaScript">
        var oEditor = FCKeditorAPI.GetInstance('PageText') ;
    </script>
    
    <button onclick="oEditor.InsertHtml(<b>test</b>);">TEST</button>
  1.     <script language="JavaScript">
  2.         var oEditor = FCKeditorAPI.GetInstance('PageText') ;
  3.     </script>
  4.     
  5.     <button onclick="oEditor.InsertHtml(<b>test</b>);">TEST</button>


any ideas? please, my time on this project is running really short!!!!
Image Eternal Truth Ministry - Biblical Resources, Forums
Have mercy on me, O God, according to your unfailing love; according to your great compassion blot out my transgressions. - Psalm 51:1 http://www.zssites.net - ZS Sites Web Hosting
  • jalil
  • Born
  • Born
  • No Avatar
  • Joined: Feb 07, 2009
  • Posts: 1
  • Status: Offline

Post February 7th, 2009, 2:59 pm

hello, just arrived at this forum.

you may wish to try

<button onclick="oEditor.InsertHtml('<b>test</b>');">TEST</button>

the quotes are needed;

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 171 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.