Hi I want to integrate the ckeditor into my small CMS. And I want to add a new option for internal sitelinks in the Link-Dialog is there any tutorial where I can read more about developing with/for ckeditor?
Thu, 09/03/2009 - 17:47
#1
Re: Additional Dialogs
this isn't the easiest to do and it is very simple to make errors while doing it, so test a lot while you are going along.
I did it and this is how I did it:
file changed
/_source/plugins/link/dialogs/link.js
First:
Add you CMS to the linktype dropdown
find the text: id : 'linkType'
this is the element which has the select box of all the options for links
in items just add a name as a handle for your CMS link this is what I did
if you don't want to hassle with the language files just write in ['Internal CMS links','cms'] instead of all the editor.lang bit
Save it. And test to see if your link has magically appeared.
Second:
You need to make selecting the item do something
find: var linkTypeChanged = function()
in the second line down add a nice name for your cms in the partIds
e.g.
Third:
create the html to appear when the cms is selected
find the id:linkType that you used before. Scroll down and look at what comes below you will notice
id: UrlOptions
and then
id: anchorOptions
with lots of interesting stuff around them.
pray to go you have a text editor that can open and close those {} brackets to make it easier to work out what starts and stop where.
you need to create a child element to sit with these with an id: cmsOptions
the simplest child you can create to prove concept would be something like below:
now when you select the CMS option you should see the message above. Now obviously what would be more useful than the message is a text area for the url and browse button that would go to your bespoke page that shows all the pages you can link to and return the url you want.
Fourth:
add a browse button
within the children area of your id: cmsOptions you need to add the button functionality
so you children area now looks like:
For easy of updating I have placed the url of bespoke page for internal links as an item in config but you could as easily have written the line:
I have used a function addQueryString to build my string which I stole from elsewhere in CKeditor. Just put this at the end of the link.js page after everything else.
Fifth:
Bits and bobs left to tidy up.
my cms links are obvious and easily seperated from normal urls as they are always prefixed with a standard path so I have added a Regex so the system can automatically know that certain links are to be rendered withthe cms dropdown rather than just url
I add my Regex (cmsRegex) in with the emailRegex anchorRegex etc
so Ithen had to alter the
to use my Regex
here is part of the function that I altered to play with my cmslinks
Sixth:
tweak the onOk function that is fired when someone clicks the OK button
in the switch/case statement I added a case 'cms' so it would do stuff with my cms link. I basically took the url case and tweaked it. Here is a simplified version of what I did (my cms had a prefix to play with as well)
Now as long as you have sacrificed to the javascript gods.. it should all work....
remember small changes and see if things have worked.
Good luck.
Re: Additional Dialogs
If you could show the sample code for the php or perl script that generates the set of cms links and the js code for how to trigger the right method in the opener once you select a cms link, that would be great.
Re: Additional Dialogs
I think cms.data is not even defined......
quite urgent guys.
Re: Additional Dialogs
Re: Additional Dialogs
Unfortunately, I'm having trouble getting started though - in Step 1, when I add my new element to the linktype in /_source/plugins/link/dialogs/link.js as follows:
I save and reload the page, but the items in the linkType dropdown have not changed - they remain:
"URL"
"Link to anchor in the text"
"E-mail"
Obviously I need to get this part working before moving on to step two. Any suggestions? Is there another file that needs to be changed or refreshed in order to get the changes to appear?
Thanks in advance!
Re: Additional Dialogs
Added this to _source/lang/en.js ('en' is set as the language in config.js - even though it should be defaulting) :
And this to _source/plugins/link/dialogs/link.js :
Re: Additional Dialogs
Re: Additional Dialogs
---
old problem:
hi, a have problem with filebrowser...
in editor configuraiton i have this:
when in this code
on last row i have filebrowser : 'info:cmsId', in pupup started KFM,
if i comment this row, in popup started correct my page...
but i this state i dont know, how i define in my page return value, i dont know how i "tell" , that this return value i will in cmsId input write...
what is wrong with parametr filebrowser: ? any idee?
(from introduction i skip article 5)
---
solution (+-):
edit: i use this solution: viewtopic.php?f=11&t=18327
Re: Additional Dialogs
I am developing a CMS and I need help with the code in this topic. My article pages will be stored in mysql. Is there any way, I can populate a list from the db.
Let me know if it is possible and if anyone can help me with the code.
Thanks,
Darshan