We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21255
    • 215 Posts
    This is an auto-generated support/comment thread for Hide Editor.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Hides editor if active template contains no content var.
      • 6726
      • 7,075 Posts
      Great to have it added into the repository, it’s such an essential plugin for me I hope lot of people will enjoy it as well !

      I just recently noticed when I chunk-ized some complex templates if the [*content*] tag is in a chunk and not directly in the template, it doesn’t display the content field undecided
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 10828 ☆ A M B ☆
        • 174 Posts
        Quote from: davidm at Apr 03, 2007, 11:33 AM

        I just recently noticed when I chunk-ized some complex templates if the [*content*] tag is in a chunk and not directly in the template, it doesn’t display the content field undecided
        Nice idea David wink

        The current version already support templates loaded via an "Include" snippet... In the following version I added the support for the [*content*] tag in a chunk. You just have to update the plugin and add this comment : [tt]<!-- {content} --> [/tt] in your template. Enjoy !
        //<?php
        /**
         * @name       Hide Editor
         * @author     Timon Reinhard <[email protected]>
         *             Gildas         <[email protected]>
         *
         * @license    GNU General Public License
         * @version    0.3.3 - 03/04/07
         *
         * @purpose    Hides editor if active template contains no content var
         *             Listens to event 'OnDocFormRender'
         *
         * @history    [Gildas      - 0.3.1 - 01/12/06] Replace setAttribute() by style.cssText for IE compatibility
         *             [Gildas      - 0.3.2 - 01/12/06] Add support for Template load via an "Include" snippet
         *             [Kratos      - 0.3.2 - 03/03/07] Add support for Default Template when creating new document (http://modxcms.com/forums/index.php/topic,2151.msg84156.html#msg84156)
         *             [Gildas      - 0.3.3 - 03/04/07] Add support for [*content*] in a Chunk (http://modxcms.com/forums/index.php?topic=13613.msg89816#msg89816)
         * 
         * @install    - Copy and paste the plugin code (without the begin/end PHP tags)
         *             - Select the "OnDocFormRender" event
         *             - If your templates are load via an "Include" snippet then add the folowing virtual parameter "content=true"
         *             - If your templates contain the content tag in a Chunk add this comment : <!-- {content} -->
         *
         * @todo       - Try to use JQuery like "Customize Manager Fields" http://modxcms.com/forums/index.php?topic=12493
         *   
         * @see        http://www.quirksmode.org/bugreports/archives/2005/03/setAttribute_does_not_work_in_IE_when_used_with_th.html
         */
        global $content, $default_template;
        
        /*
         * Collect current MODx Event & Template ID
         */
        $e      = &$modx->Event;
        $tempid = (isset($content['template']) ? $content['template'] : $default_template);
        
        /*
         * Check the Event and the document content
         */
        if (($e->name == 'OnDocFormRender') && ($tempid > 0)) {
            /*
             * Load the document template 
             */
            if (($template = $modx->db->getValue("SELECT content FROM {$modx->db->config['table_prefix']}site_templates WHERE id = $tempid")) !== false) {
                /*
                 * Check for a "content" tag in the template
                 */
                if ((strpos($template, '[*content*]') === false) && (strpos($template, '[*#content*]') === false) && (strpos($template, 'content=true') === false) && (strpos($template, '<!-- {content} -->') === false)) {
                    /*
                     * Create the JS code to hide the "Document area"
                     */
                    $output = '<!-- HideEditor Plugin -->';
                    $output.= '<script type="text/javascript">';
                    $output.= 'document.getElementById(\'ta\').parentNode.parentNode.previousSibling.style.cssText = \'display:none\';';
                    $output.= 'document.getElementById(\'ta\').parentNode.parentNode.style.cssText = \'display:none\';';
                    $output.= '</script>';
                    
                    /*
                     * Output the JS code 
                     */
                    $e->output($output);
                }
            }
        }
        
          Ackwa - Web Design & Development agency | Tours - France | Follow me on Twitter...
          • 6726
          • 7,075 Posts
          Yeah I saw there was a parameter for people who include their templates (&content=true) and tried it but I missed the <!-- {content} --> thing : very cool !

          Thanks grin
          You rock !

          Edit : Just tried it, works perfect !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 32358
            • 2 Posts
            Thank you very much for this, exactly what I needed and worked perfectly. smiley
              • 29076
              • 615 Posts
              Thanks for a small, but great snippet. I use it all over.
                I think, thererfor I am! But what I am, and why...?
                • 31961
                • 23 Posts
                Just to let you know that this plugin doesn’t work in the latest release of MODX 0.9.6.2 :’(
                  • 5340
                  • 1,624 Posts
                  Doesn’t work in 0.9.6.3 RC2 either
                    • 5340
                    • 1,624 Posts
                    new version here
                    http://modxcms.com/Hide-Editor-0.3.3-2287.html

                    Changed it to use the default mootools.js(this should work for all versions. Works in IE6,IE7,Firefox)
                      • 7231
                      • 4,205 Posts
                      Do you have the <?php ?> tags in the plug-in? Plugins don’t need the tags, they shuld either be commented out //<?php or erased.
                        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                        Something is happening here, but you don&#39;t know what it is.
                        Do you, Mr. Jones? - [bob dylan]