Where does this ckeditor method go?

I have designed a custom file browser for ckeditor. When I click on the Browse Server button in the image properties dialog for ckeditor, my file browser loads correctly and lets me pick a file...everything works perfectly.

The problem is with this function in the if (isset($vars['file'])) block that I attached to this posting.
I'm not sure where to put this. I put it in the custom file browser but when it runs, it complains that window.parent.CKEDITOR is undefined. I tried to add

            if (isset($vars['file']))
            {
                  $funcNum = $vars['CKEditorFuncNum'];
                  $script = "<script type='text/javascript' src='../plugins/ckeditor/ckeditor.js'></script>";
                  $script .= "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '{$vars['file']}');window.close();</script>";
                  print $script;

thereby making the CKEDITOR available but this simply closes the window and does not populate the selected file field.

What do you suggest?
if (isset($vars['file']))
		{
			$funcNum = $vars['CKEditorFuncNum'];
			$script = "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '{$vars['file']}');window.close();</script>";
			print $script;

Open in new window

LVL 3
rae_raeAsked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
>>Yes because without '../plugins/ckeditor/ckeditor.js', it throws an error stating that CKEDITOR is not defined
My point exactly. It needs to find it. If the path is wrong, the browser is not able to download it and you get the error described. I am not suggesting to get rid of ../plugins/ckeditor/ckeditor.js, I am suggesting to provide the full path. In other words, open a new browser window and type:
http://localhost/ckeditor.js

is the browser able to download it? Yes=> then use that path
 $script = "<script type='text/javascript' src='http://localhost/ckeditor.js'></script>";


No=>You still don't have the right path, keep looking for the right path to your js file, perhaps:
http://localhost/cms/ckeditor.js

did it download now? No, keep looking...
get it?

Once you know for sure you have the right path, then get rid of "http://localhost" so that ultimately the path will start with a leading slash - ex:

 $script = "<script type='text/javascript' src='/path/to/ckeditor.js'></script>";
0
 
hieloCommented:
>>window.parent.
That is looking for CKEDITOR in a parent window. But that implies that current window must be opened via window.open() (as opposed to some floating div).

>> I tried to add
>> $script = "<script type='text/javascript' src='../plugins/ckeditor/ckeditor.js'></script>";
In that case, do NOT use "window.parent."

$script .= "<script type='text/javascript'>CKEDITOR.tools.callFunction($funcNum, '{$vars['file']}');window.close();</script>";
0
 
rae_raeAuthor Commented:
Thank you for the info. Any is extremely appreciated.

I did try what you were saying and removed the reference to window.parent:
                  $script = "<script type='text/javascript' src='../plugins/ckeditor/ckeditor.js'></script>";
                  $script .= "<script type='text/javascript'>CKEDITOR.tools.callFunction($funcNum, '{$vars['file']}');window.close();</script>";
                  print $script;

This seems to yield the same result as before however. Perhaps I am including this code in the wrong place? I have this in the custom file browser I defined which is a different window than the ckeditor. The ckeditor opens the custom browser which does not seem to be aware of the ckeditor presence.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
hieloCommented:
are you sure the browser is able to locate the js file? Instead of:
../plugins/ckeditor/ckeditor.js

try supplying the full url - ex:
http://www.yoursite.com/javascript/plugins/ckeditor/ckeditor.js
0
 
rae_raeAuthor Commented:
Yes because without '../plugins/ckeditor/ckeditor.js', it throws an error stating that CKEDITOR is not defined. You can actually see that my file browser is passing back the vars correctly too:
http://localhost/cms/pages/listfiles.php?CKEditor=content_body&CKEditorFuncNum=2&langCode=en&site=faculty&site=faculty&file=..%2Fsites%2Ffaculty%2Fimages%2F12938_513078879655_100401082_30463653_5802983_n.jpg

Note especially the CKEditor, CKEditorFuncNum, langCode and file parameter. All of these are required to send back to CKEditor so I know that this is not the problem. Hm....
0
 
rae_raeAuthor Commented:
I got it! oh wow...reading helps. I must have read this several times now but realized that I must have misread the title on different items over at http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29/Custom_File_Browser#Passing_the_URL_of_selected_file

I used example 2: Sending the url from file browser (JavaScript) instead of example 3 Sending back the url of uploaded file from PHP connector....so sorry to waste your time.

You get the points though. Thank you so much for helping out with this.
0
 
rae_raeAuthor Commented:
Just having your help was really awesome. I appreciate you looking into this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.