TinyMCE für Teaser hinzufügen

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • Rumfuchser
    Contao-Nutzer
    • 12.01.2010
    • 40

    #1

    TinyMCE für Teaser hinzufügen

    Hi,

    ich kämpfe mit einem Problem.

    Ich möchte bei der Eingabe neuer Events dem Teaser-Eingabefeld bestimmte TinyMCE-Funktionen hinzufügen.

    Ich erstelle also eine Datei namens "tinyMCE_custom.php", füge dort den Inhalt der tinyMCE.php ein und bearbeite meinen Wünschen entsprechend.

    Dann gehe ich in system/config und füge der dcaconfig.php folgende Codezeile hinzu:
    Code:
    $GLOBALS['TL_DCA']['tl_calendar_events']['fields']['teaser']['eval']['rte'] = 'tinyMCE_custom';
    Jetzt hat das Teaserfeld in der Tat die TinyMCE-Funktionen. Entferne ich die Zeile wieder aus der Datei, verschwindet die TinyMCE-Funktionalität wieder. Soweit so gut.

    Nur, wie man der Zeile entnehmen kann, möchte ich nur spezielle Funktionen. Er läd allerdings immer alle, also die tinyMCE.php. Ändere ich die tinyMCE meinen Wünschen entsprechend, sieht das Teaserfeld zwar richtig aus, dafür aber - logischerweise - alle anderen nicht mehr.

    Welchen Schritt hab ich vergessen? Muss ich noch irgendwas machen, damit er meine Custom-Datei nimmt?
  • Rumfuchser
    Contao-Nutzer
    • 12.01.2010
    • 40

    #2
    Keiner eine Idee?

    Kommentar

    • Rumfuchser
      Contao-Nutzer
      • 12.01.2010
      • 40

      #3
      Wo widerspreche ich mir?
      Genau durchlesen. Die Sache ist schon kurios - bzw. ich erkenn den Fehler nicht. :-)

      Poste morgen mal die Dateien, kann ich grad nicht.

      Kommentar

      • andre.5tz
        Contao-Fan
        • 19.06.2009
        • 464

        #4
        Hallo,

        ich kann das von Rumfuchser beschriebene Verhalten bestätigen, bzw. habe das gleiche Problem.

        Für den Teasertext habe ich nach dem Buch "Websites erstellen mit Contao" von Peter Müller den TinyMCE eingerichtet.
        Anschließend wollte ich für den Teaser einen abgespeckten TinyMCE einrichten und habe ebenfalls dafür eine eigene Datei für den TinyMCE (TinyTeaser.php) angelegt und darauf verwiesen.
        Ergebnis: Der RTE wird immer nach der Datei TinyMCE.php ausgegeben.

        Ich wüsste daher ebenfalls gerne, ob ich noch irgend etwas einrichten muss oder ob es einfach nicht möglich ist, den TinyMCE für einen Teaser anders zu konfigurieren wie für den Nachrichtentext.

        VG
        André

        Kommentar

        • pmmueller
          Buchautor 'Websites erstellen mit Contao'
          • 19.06.2009
          • 1523

          #5
          Ich weiß nicht, ob man auf ein und derselben Seite zwei verschiedene Konfigurationen für den TinyMCE laden kann. Habe ich nie ausprobiert (und im Moment auch keine Zeit dazu).
          • Auf Seite 514 im Buch wird die Konfig-Datei "tinyMini" sowohl für Teaser als auch für Text geladen.
          • Auf Seite 515 wird dann beschrieben, wie man die TinyMCE-Konfig für Benutzergruppen anpassen kann. Das geht.
          Aber ob man auf einer Seite zwei verschiedene Konfigs laden kann? Euren Posting zufolge würde ich mal sagen, dass das nicht geht
          »pmueller.de« | »groningen-info.de«

          Kommentar

          • andre.5tz
            Contao-Fan
            • 19.06.2009
            • 464

            #6
            @pmmueller
            Danke für die schnelle Antwort. Dein Buch habe ich ja gelesen und viele nützliche Tipps gefunden

            Wenn ich es richtig verstanden habe, besteht grundsätzlich die Möglichkeit, den TinyMCE mehrfach und mit unterschiedichen Konfigurationen auf einer Seite einzubinden.



            Nur müsste das Contao noch irgendwie mitgeteilt werden und genau daran scheitern wir wohl gerade

            Kommentar

            • andre.5tz
              Contao-Fan
              • 19.06.2009
              • 464

              #7
              Habe jetzt eine Lösung gefunden.

              Zuerst sollte eine eigene updatesichere Version des TinyMCE erwendet werden. Einstellungen wie im WIKI beschrieben.

              Updatesicheres Anpassen der system/config/tinyMCE.php

              Anschließend die eigene kopierte Datei anpassen. Der anhängende Code ist die gerade von mir erstellte tinyCustom.

              Wichtig hierbei ist, daß der Teil von "tinyMCE.init({..." bis "...});"
              zwei mal eingebunden ist und das im zweiten Teil der Code
              'elements : "<?php echo $this->rteFields; ?>",' durch
              'elements : "ctrl_teaser",'
              ersetzt wird.

              Durch die Einstellung müssten jetzt alle Teaser einen Abgespeckten TinyMCE erhalten, für deren Textareas eine tinyCustom eingestellt wurde.
              Anpassungen sind natürlich nach eigenen Vorstellungen möglich.

              Für Verbesserungsvorschläge bin ich offen.

              Code:
              <?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
              
              /**
               * Contao Open Source CMS
               * Copyright (C) 2005-2011 Leo Feyer
               *
               * Formerly known as TYPOlight Open Source CMS.
               *
               * This program is free software: you can redistribute it and/or
               * modify it under the terms of the GNU Lesser General Public
               * License as published by the Free Software Foundation, either
               * version 3 of the License, or (at your option) any later version.
               * 
               * This program is distributed in the hope that it will be useful,
               * but WITHOUT ANY WARRANTY; without even the implied warranty of
               * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
               * Lesser General Public License for more details.
               * 
               * You should have received a copy of the GNU Lesser General Public
               * License along with this program. If not, please visit the Free
               * Software Foundation website at <http://www.gnu.org/licenses/>.
               *
               * PHP version 5
               * @copyright  Leo Feyer 2005-2011
               * @author     Leo Feyer <http://www.contao.org>
               * @package    Config
               * @license    LGPL
               * @filesource
               */
              
              
              /**
               * This is the tinyMCE (rich text editor) configuration file. Please visit
               * http://tinymce.moxiecode.com for more information.
               */
              if ($GLOBALS['TL_CONFIG']['useRTE']): ?>
              <script type="text/javascript" src="<?php echo $this->base; ?>plugins/tinyMCE/tiny_mce_gzip.js"></script>
              <script type="text/javascript">
              <!--//--><![CDATA[//><!--
              tinyMCE_GZ.init({
                plugins : "advimage,autosave,directionality,emotions,inlinepopups,paste,save,searchreplace,spellchecker,style,tabfocus,table,template,typolinks,xhtmlxtras",
                themes : "advanced",
                languages : "<?php echo $this->language; ?>",
                disk_cache : false,
                debug : false
              });
              //--><!]]>
              </script>
              <script type="text/javascript">
              <!--//--><![CDATA[//><!--
              tinyMCE.init({
                mode : "exact",
                height : "500",
                language : "<?php echo $this->language; ?>",
                elements : "<?php echo $this->rteFields; ?>",
              <?php if ($this->brNewLine): ?>
                forced_root_block : false,
                force_p_newlines : false,
                force_br_newlines : true,
              <?php endif; ?>
                remove_linebreaks : false,
                force_hex_style_colors : true,
                fix_list_elements : true,
                fix_table_elements : true,
                theme_advanced_font_sizes : "9px,10px,11px,12px,13px,14px,15px,16px,17px,18px,19px,20px,21px,22px,23px,24px",
                doctype : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
                document_base_url : "<?php echo $this->base; ?>",
                entities : "160,nbsp,60,lt,62,gt,173,shy",
                cleanup_on_startup : true,
                save_enablewhendirty : true,
                save_on_tinymce_forms : true,
                save_callback : "TinyCallback.cleanXHTML",
                init_instance_callback : "TinyCallback.getScrollOffset",
                advimage_update_dimensions_onchange : false,
                external_image_list_url : "<?php echo TL_PATH; ?>/plugins/tinyMCE/plugins/typolinks/typoimages.php",
                template_external_list_url : "<?php echo TL_PATH; ?>/plugins/tinyMCE/plugins/typolinks/typotemplates.php",
                plugins : "advimage,autosave,directionality,emotions,inlinepopups,paste,save,searchreplace,spellchecker,style,tabfocus,table,template,typolinks,xhtmlxtras",
                spellchecker_languages : "<?php echo $this->getSpellcheckerString(); ?>",
                content_css : "<?php echo TL_PATH; ?>/system/themes/tinymce.css,<?php echo TL_PATH .'/'. $this->uploadPath; ?>/tinymce.css",
                event_elements : "a,div,h1,h2,h3,h4,h5,h6,img,p,span",
                extended_valid_elements : "q[cite|class|title]",
                tabfocus_elements : ":prev,:next",
                theme : "advanced",
                theme_advanced_resizing : true,
                theme_advanced_resize_horizontal : false,
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_statusbar_location : "bottom",
                theme_advanced_source_editor_width : "700",
                theme_advanced_blockformats : "div,p,address,pre,h1,h2,h3,h4,h5,h6",
                theme_advanced_buttons1 : "newdocument,save,separator,spellchecker,separator,anchor,separator,typolinks,unlink,separator,image,typobox,separator,sub,sup,separator,abbr,acronym,separator,styleprops,attribs,separator,search,replace,separator,undo,redo,separator,removeformat,cleanup,separator,code",
                theme_advanced_buttons2 : "formatselect,fontsizeselect,styleselect,separator,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,indent,outdent,separator,blockquote,separator,forecolor,backcolor",
                theme_advanced_buttons3 : "tablecontrols,separator,template,separator,charmap,emotions,separator,help"
              });
              tinyMCE.init({
                mode : "exact",
                height : "200",
                language : "<?php echo $this->language; ?>",
                elements : "ctrl_teaser",
              <?php if ($this->brNewLine): ?>
                forced_root_block : false,
                force_p_newlines : false,
                force_br_newlines : true,
              <?php endif; ?>
                remove_linebreaks : false,
                force_hex_style_colors : true,
                fix_list_elements : true,
                fix_table_elements : true,
                doctype : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
                document_base_url : "<?php echo $this->base; ?>",
                entities : "160,nbsp,60,lt,62,gt,173,shy",
                cleanup_on_startup : true,
                save_enablewhendirty : true,
                save_on_tinymce_forms : true,
                save_callback : "TinyCallback.cleanXHTML",
                init_instance_callback : "TinyCallback.getScrollOffset",
                advimage_update_dimensions_onchange : false,
                external_image_list_url : "<?php echo TL_PATH; ?>/plugins/tinyMCE/plugins/typolinks/typoimages.php",
                template_external_list_url : "<?php echo TL_PATH; ?>/plugins/tinyMCE/plugins/typolinks/typotemplates.php",
                plugins : "advimage,autosave,directionality,emotions,inlinepopups,paste,save,searchreplace,spellchecker,style,tabfocus,table,template,typolinks,xhtmlxtras",
                spellchecker_languages : "<?php echo $this->getSpellcheckerString(); ?>",
                content_css : "<?php echo TL_PATH; ?>/system/themes/tinymce.css,<?php echo TL_PATH .'/'. $this->uploadPath; ?>/tinymce.css",
                event_elements : "a,div,h1,h2,h3,h4,h5,h6,img,p,span",
                extended_valid_elements : "q[cite|class|title]",
                tabfocus_elements : ":prev,:next",
                theme : "advanced",
                theme_advanced_resizing : true,
                theme_advanced_resize_horizontal : false,
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_statusbar_location : "bottom",
                theme_advanced_source_editor_width : "700",
                theme_advanced_blockformats : "div,p,address,pre,h1,h2,h3,h4,h5,h6",
                theme_advanced_buttons1 : "bold,italic,underline,separator,bullist,numlist,indent,outdent,separator,typolinks,unlink,separator,image,typobox,separator,sub,sup,separator,abbr,acronym,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,blockquote,separator,undo,redo,separator,removeformat,cleanup,separator,code",
                theme_advanced_buttons2 : "",
                theme_advanced_buttons3 : ""
              });
              
              //--><!]]>
              </script>
              
              <?php endif; ?>
              Zuletzt geändert von andre.5tz; 29.04.2011, 22:12.

              Kommentar

              • andre.5tz
                Contao-Fan
                • 19.06.2009
                • 464

                #8
                Bei meiner aufgezeigten Lösung sollte der Artikel Teaser nicht, wie im Wiki beschrieben, mit der oben erstellten TinyCustom.php verbunden werden. Das hat gerade bei mir zu Problemen geführt

                D.h., der Bereich aus dem Wiki
                Code:
                // Die eigene RTE-Konfiguration verwenden für
                  //Artikel-Teaser
                  $GLOBALS['TL_DCA']['tl_article']['fields']['teaser']['eval']['rte'] = 'tinyCustom';
                sollte nicht mit der oben aufgeführten tinyCustom in die localconfig.php übernommen werden. Für diesen Teaser entweder die original tinyMCE.php belassen oder eine eigene Datei erstellen und darauf verweisen.

                VG
                André

                Kommentar

                Lädt...