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
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
-
☆ 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 
Nice idea David
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);
}
}
}
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

You rock !
Edit : Just tried it, works perfect !
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
Thanks for a small, but great snippet. I use it all over.
I think, thererfor I am! But what I am, and why...?
Just to let you know that this plugin doesn’t work in the latest release of MODX 0.9.6.2 :’(
Doesn’t work in 0.9.6.3 RC2 either
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.