<![CDATA[ Tip: Different styles in TimyMce (2.1.1.x) editor for different templates - My Forums]]> https://forums.modx.com/thread/?thread=45846 <![CDATA[Re: Tip: Different styles in TimyMce (2.1.1.x) editor for different templates]]> https://forums.modx.com/thread/45846/tip-different-styles-in-timymce-2-1-1-x-editor-for-different-templates#dis-post-265418 Sorry about that smiley Not trying to impersonate you,... honest smiley
]]>
TobyL May 27, 2007, 09:01 AM https://forums.modx.com/thread/45846/tip-different-styles-in-timymce-2-1-1-x-editor-for-different-templates#dis-post-265418
<![CDATA[Re: Tip: Different styles in TimyMce (2.1.1.x) editor for different templates]]> https://forums.modx.com/thread/45846/tip-different-styles-in-timymce-2-1-1-x-editor-for-different-templates#dis-post-265417 ]]> opengeek May 26, 2007, 12:45 PM https://forums.modx.com/thread/45846/tip-different-styles-in-timymce-2-1-1-x-editor-for-different-templates#dis-post-265417 <![CDATA[Tip: Different styles in TimyMce (2.1.1.x) editor for different templates]]> https://forums.modx.com/thread/45846/tip-different-styles-in-timymce-2-1-1-x-editor-for-different-templates#dis-post-265416
1. I have a general editor style sheet: assets/site/tinymce.css which is set in the site configuration. Next to that I’ve created style sheets for each template where I want to divert from the default. I’ve named these template1.css, template2.css etcetera. The number is the id of each template.

2. I made 3 changes in the TinyMCE plugin code.
Firstly it needs access to the global $content variable.
<?php
// Handle event
global $content; //mod by JJC
$e = &$modx->Event; 
?>


Then a test to see if an editor css file exists in the onRichTextEditorInit event and replace the occurence of $modx->config[’editor_css_path’] in both the getTinyMCEScript() calls with the $tiny_mce_path variable created earlier.
<?php
    case "OnRichTextEditorInit": 
  
    //check if template has it's own editor css file
    $tiny_css_path = $modx->config['editor_css_path']; //set default css file
    $template_css = 'assets/site/template'.$content['template'].'.css';
    if( file_exists($modx->config['base_path'] . $template_css) ) 
      $tiny_css_path = $modx->config['base_url'].$template_css;

    if($editor=="TinyMCE") {
      $elementList = implode(",", $elements);
      if(isset($forfrontend)||$modx->isFrontend()){
        $frontend = 'true';
        $frontend_language = isset($modx->config['fe_editor_lang']) ? $modx->config['fe_editor_lang']:"";
        $tinymce_language = getTinyMCELang($frontend_language);
        $html = getTinyMCEScript($elementList,$webtheme,$width,$height,$tinymce_language,$frontend,$base_url, $webPlugins, $webButtons1, $webButtons2, $webButtons3, $webButtons4, $disabledButtons, $tinyFormats, $entity_encoding, $entities, $tinyPathOptions, $tinyCleanup, $tinyResizing, $tiny_css_path, $modx->config['tinymce_css_selectors'], $modx->config['use_browser'], $webAlign, null, null, $tinyLinkList);
      } else {
        $frontend = 'false';
        $manager_language = $modx->config['manager_language'];
        $tinymce_language = getTinyMCELang($manager_language);
        $html = getTinyMCEScript($elementList, $modx->config['tinymce_editor_theme'], $width='100%', $height='400px', $tinymce_language, $frontend, $modx->config['base_url'], $modx->config['tinymce_custom_plugins'], $modx->config['tinymce_custom_buttons1'], $modx->config['tinymce_custom_buttons2'], $modx->config['tinymce_custom_buttons3'], $modx->config['tinymce_custom_buttons4'], $disabledButtons, $tinyFormats, $entity_encoding, $entities, $tinyPathOptions, $tinyCleanup, $tinyResizing, $tiny_css_path, $modx->config['tinymce_css_selectors'], $modx->config['use_browser'], $modx->config['manager_direction'], $advimage_styles, $advlink_styles, $tinyLinkList);
      }
      $e->output($html);
    }    

?>



I only pasted the bits of code where I actually made changes. I deliberately didn’t paste the whole plugin code as I did this from the 096RC base. There may be changes by the time the final 096 is released. Take this as an exercise of "spot the difference" and take it from there. smiley]]>
TobyL May 26, 2007, 01:22 AM https://forums.modx.com/thread/45846/tip-different-styles-in-timymce-2-1-1-x-editor-for-different-templates#dis-post-265416