I would like to offer my users an easy way to use some styles that are available in the theme. How would you enable the style dropdown that is available in TMCE?

Comments

Steve Lockwood’s picture

Status: Active » Fixed

Here's an approach that seems to work.
- go to admin/settings/tinytinymce
- edit the init script for advanced mode (for example)
- add the following to theme_advanced_buttons1
theme_advanced_buttons1 : "..., styleselect,...",
- add the following line
content_css: "/path/to/your/sites/stylesheet.css"
- in the stylesheet referenced above any class associated with divs will appear in the dropdown, eg
div.waytoobright {color: yellow; background-color: red;}

I used a stylesheet that is already associated with the theme. I'm not sure if it would work if you referenced a stylesheet not already linked in to Drupal either using a theme or a module.

I hope this helps

ñull’s picture

Thanks a lot. Yes I forgot that you can just customise the init script. This however only allows to use one theme. If you allow users to change theme, the chosen CSS should work in all themes. Would be nice when there is a way to "switch" CSS.

Steve Lockwood’s picture

I have not tried this but I think you could trick the editor:

Set the content_css parameter as described above and create a stylesheet at that location which has the styles that you want.

When the user selects that style it just creates a div with that class.

You would then need to alter the actual stylesheets which are in use to make sure that they also have your styles defined in them
- method 1 would be to alter one of the default Drupal stylesheets that is always present
- method 2 would be to alter the stylesheets for all the themes that are in use
- method 3 would be to put an @import into all the theme stylesheets which links to a common stylesheet with the classes you want

I hope this makes sense and is of use.

Steve

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.