Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ckeditor Link with basepath

Tags:

php

ckeditor

Im using CKeditor however i test it on a staging environment. Then i move it to production. The problem is when im linking i dont want to use mysite.com because then it will only work on staging or production but not on both. Instead i would like to use my basepath php variable which will auto determine to use mysite.com/ or staging.mysite.com

Is there any way to do this with the CKeditor URL link option. I have tried setting it to:

/myfolder/mypage.php

Using the other protocol, however it sets the URL as http///myfolder/mypage.php

Is this possible or is there an addon that can do this for me?

My config.js file as requested:

CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
};

I did find out how to change the basepath for Ckeditor but this is just where ckeditor install path is, i need to set a different path which is just the basepath

Just to clarify as a picture speaks a thousand words and all:

Its this create a link option in the Ckeditor toolbar that allows you to create a URL link that i am referring to

enter image description here

like image 387
user1547410 Avatar asked Oct 24 '15 12:10

user1547410


1 Answers

I know this isn't ideal as it's a hack, but you can go to ckeditor/plugins/link/dialogs/link.js find this in the code:

label:i.protocol,"default":"http://",items:[["http://‎","http://"],["https://‎","https://"],["ftp://‎","ftp://"],["news://‎","news://"],[b.other,""]]

Then just add another option in the items array like ["Base URL","/"].

I did find this solution that may also suit your needs: http://ckeditor.com/forums/CKEditor-3.x/internal-pages-dropdown-link-dialog

Hope that helps.

like image 192
Michael Avatar answered Sep 23 '22 16:09

Michael