WYSIWYG different styles?

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 28, 2013   (RSS)

Hi Guys,

I have a wysiwyg-custom.css file that is loading a number of styles into the styleselect drop down.  I'm wondering if I can load a different wysiwyg-custom.css for different sections of the CMS. 

I really only need 2 different sets, so whether it loads different files, or maybe have the css as a php page and have somethign along the lines of "if section type A - shows these styles, or if section type B - show these styles"

Any ideas?

Cheers,

Tim (toledoh.com.au)

Hi Tim,

There isn't currently an easy way to do this. But I've found a workaround you can use. If you open /cmsAdmin/lib/wysiwyg.php around line 34 you should see two lines likes this:

  $wysiwygCssFilename    = file_exists( dirname(__FILE__) .'/wysiwyg_custom.css' ) ? 'wysiwyg_custom.css' : 'wysiwyg.css';
  $wysiwygCssModified    = filemtime( dirname(__FILE__) ."/$wysiwygCssFilename" );

If you wanted to change it so that a different css file was used for certain sections, you could do something like this:

  // load either wysiwyg_custom.css (if exists) or wysiwyg.css
  $wysiwygCssFilename    = file_exists( dirname(__FILE__) .'/wysiwyg_custom.css' ) ? 'wysiwyg_custom.css' : 'wysiwyg.css';
  if(@$_REQUEST['menu'] == 'blog'){ $wysiwygCssFilename = 'blog.css'; }
  $wysiwygCssModified    = filemtime( dirname(__FILE__) ."/$wysiwygCssFilename" );

So if a section has a WYSIWYG editor, this if statement checks if it is for the blog section, and then loads blog.css instead. 

You would have to store blog.css in the same directory that wysiwyg_custom.css is stored. 

As this is a change to a core CMS Builder file, any future upgrades would remove this functionality.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Works perfectly - and if you change wwysiwyg.php to wysiwyg_custom.php is won't get overwritten... cool!

Cheers,

Tim (toledoh.com.au)