On the ckeditor demo I see no way of switching the content's css.
There is mention of a plugin - is it just not installed on the demo?
What I'd like to achieve is the ability to switch the css (to arrive at a different background) thru the editor.
Is this possible?
<link rel="stylesheet" type="text/css" href="/templates/flyer_01_00.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Dark Green"
href="/templates/flyer_01_01.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Magenta"
href="/templates/flyer_01_02.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Gold"
href="/templates/flyer_01_03.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Aqua"
href="/templates/flyer_01_04.css" />
Thanks for your time,
michael
There is mention of a plugin - is it just not installed on the demo?
What I'd like to achieve is the ability to switch the css (to arrive at a different background) thru the editor.
Is this possible?
<link rel="stylesheet" type="text/css" href="/templates/flyer_01_00.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Dark Green"
href="/templates/flyer_01_01.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Magenta"
href="/templates/flyer_01_02.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Gold"
href="/templates/flyer_01_03.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Aqua"
href="/templates/flyer_01_04.css" />
Thanks for your time,
michael
Re: switching between content alt stylesheets
To initially apply a stylesheet, you can use the .contentsCss config entry. Just add that entry in one of the locations described in this Developer's Guide article.
In order to switch between them, I found this appendStyleSheet function attached to the document namespace that you could use.
The code would look like this:
Unfortunately this only gets us half the way, it adds the new stylesheet, but does not remove the old one.
However, if you are only using
in your stylesheets, then the new stylesheet should override the old one's styles. (Just confirmed it using a test page, it does work.) It works quite well, in fact, because it appears that CKEditor doesn't care about the style data. The only downside is when switching between Source and WYSIWYG modes you will lose the appended style and it will be replaced with the original one defined in contentCss of the editor's config.
Hope this helps.
Re: switching between content alt stylesheets
to make it all stick some voodoo ajax or js possibly will be required.
with FF & IE8, the alt.stylesheets can be selected in the view menu.
thanks also for the code examples.