How would I go about changing the text editor?

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
TheCodeRed
Posts: 26
Joined: 2014-05-01 12:57

How would I go about changing the text editor?

Post by TheCodeRed » 2014-07-25 21:49

Hello,

So, I am using one of my many applications as a content management system. So far everything is going swimmingly. however, I would like to be able to embed html code and it seems that you can't do this in the most current text editor in detail view. There is no button for source or and option for code. There is only standard change font color, bg color, images, links, font sizes and such.

If you post the <embed> code directly in the detail view text editor it turns it into text on display in my output to website. I am sure I can go into the backend of the MySQL db and do this on those occasions, however I would like to make it easier as it is a function most people use. Whether making a blog app, cms, data management. I could swear that it used to function that way but now it is more user friendly and less coder friendly.

So.. I guess what i want to know is where do I go about changing the text editor in use on the detail screen for the Rich HTML field types. If I have to I will try to implement ckeditor of sorts but I would rather just see a function that allows me to go to the source of the field instead of the display output.

As always,
Kind Regards - Red

User avatar
a.gneady
Site Admin
Posts: 1354
Joined: 2012-09-27 14:46
Contact:

Re: How would I go about changing the text editor?

Post by a.gneady » 2014-07-25 22:38

Hmm .. I'd suggest that you set the field as a normal text area rather than rich HTML in AppGini. Then add a new file in the hooks folder and name it "tablename-dv.js" (where tablename is the name of the concerned table) ... This is a "magic file", meaning that once created in the hooks folder, it will be automatically loaded by your application ... *-dv.js files are loaded in the detail view ... In that file, you should add the javascript code for applying the third-party HTML editor to your text area. For ckEditor, according to http://docs.ckeditor.com/#!/guide/dev_installation , the code would be:

Code: Select all

CKEDITOR.replace( 'fieldname' );
You also need to load the ckEditor component .. To do so, the simplest way is to edit the geenrated "header.php" file to add this line to the <head> section:

Code: Select all

<script src="path/to/ckeditor.js"></script>
You need to re-apply the above edit to the header.php file if you regenerate your application later. To avoid this, you could use the tablename_header hook instead: http://bigprof.com/appgini/help/advance ... ame_header
:idea: AppGini plugins to add more power to your apps:

TheCodeRed
Posts: 26
Joined: 2014-05-01 12:57

Re: How would I go about changing the text editor?

Post by TheCodeRed » 2014-07-28 19:50

Thank you as always. I will give this a try this evening and report back. Of course I would have to change the field type to text and regenerate my code/template files. Correct?

Post Reply