This post shows a way of doing the above, but does end with a question.

I customised the TinyMCE HTML editor in the admins of the mezzanine pages 
and blog posts. I did this by making a copy of the tinymce_setup.js into my 
project, customising the copy, then pointing at it using the mezzanine 
setting TINYMCE_SETUP_JS. This worked fine.

I added a new app to my project. It has a model which is unrelated to any 
of the mezzanine page types. I wanted a text field in this model to have 
tinyMCE attached to it. I was happy that timyMCE should behave exactly the 
same as the pages and blog post content fields.

*How not to do it*

Neither of these worked:

   1. Setting the CSS class name of the text field to "mceEditor", in my 
   app's admin.py.
   2. In the custom tinyMCE initialisation code, changing mode to "exact" 
   and adding an elements argument containing the CSS ID of my text field.
   
The problem seemed to be that the custom init code simply did not run for 
my app/model. 

*A way of doing it*

In my app's admin.py

from django.contrib import admin
> from django.db import models
> from mezzanine.core.forms import TinyMceWidget
> from .models import MyModel
> class MyModelAdmin(admin.ModelAdmin):
>     formfield_overrides = { models.TextField: {'widget' : TinyMceWidget}, }
> admin.site.register(MyModel, StaffMemberAdmin)


No changes to the custom TinyMCE init code were needed.

*The Question*

I now have another app and model with a text field to which I need to 
attach TinyMCE. However, this time I need to really restrict what TinyMCE 
is allowed to do (so the client cannot mess the site up, sigh) so this 
instance will need to run a different initialisation function i.e. it is 
now app-specific rather than project-wide. 

Can anybody suggest a way of doing this which won't cause deployment or 
maintenance problems?







-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to