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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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
hieloCommented:
>>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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.