By johnnyd on
I have tinymce working in Drupal 5, however, if I set the input format to "PHP code" on a node and try to enter in PHP code, tinymce filteres it out. I tried clicking on the HTML link in tinymce's toolbar and entering in the PHP code there, but tinymce still filtered it out. Does anyone know of a valid_elements option I can set in the tinymce configuration that would instruct tinymce to allow PHP tags? Thanks!
Comments
I have the same issue. Any
I have the same issue. Any ideas how to solve that? Thank you!
-------------------------------
www.Bossite.com
Live from Prague, Czech republic
-------------------------------
Surely it would be simpler
Surely it would be simpler to just set tinymce to not show if php input is selected? And I would love to know how to do that...
Agreed. Hopefully we will
Agreed. Hopefully we will find someone who knows.
-------------------------------
www.Bossite.com
Live from Prague, Czech republic
-------------------------------
A tedious solution, but
A tedious solution, but the way I have done this is to simply exclude every specific text input field by excluding them in the tinymce.module. This has only been done on pages where tinymce is enabled but there are some fields where I do not wish it to be enabled, such as a php input field. If this is of use to anyone else, you need to find the following in tinymce.module :
function theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
switch ($textarea_name) {
// Disable tinymce for these textareas
case 'log': // book and page log
case 'img_assist_pages':
case 'caption': // signature
case 'pages':
case 'access_pages': //TinyMCE profile settings.
case 'user_mail_welcome_body': // user config settings
case 'user_mail_approval_body': // user config settings
case 'user_mail_pass_body': // user config settings
case 'field-teaser-description-0-value': // MANUALLY ADDED FIELD TO EXCLUDE
case 'allowed-values': // MANUALLY ADDED FIELD TO EXCLUDE
case 'allowed-values-php': // MANUALLY ADDED FIELD TO EXCLUDE A PHP INPUT FIELD
case 'default-value-php': // MANUALLY ADDED FIELD TO EXCLUDE A PHP INPUT FIELD
case 'synonyms': // taxonomy terms
case 'description': // taxonomy terms
unset($init);
break;
No doubt this could and should be done in the template file at the theme level, but I haven't figure that out yet...
how do you run PHP and HTML
how do you run PHP and HTML in the same textarea when using tinymce?
I can only seem to use html, the php gets htmlentities'ized
thanks.
using hook_filter
If you are willing to use a custom token rather than the proper php tags, you can create a module that implements hook_filter to override the PHP evaluator input format filter.
You would basically define a new filter that behaves almost exactly like the PHP evaluator, except it modifies the data before it is sent to drupal_eval (the actual php evaluator function), replacing your custom token with valid php tags.
function modulename_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'list':
return array(0 => t('PHP tinymce workaround'));
case 'no cache':
return $delta == 0; // No caching
case 'description':
switch ($delta) {
case 0:
return t('Converts your tokens to php tags');
default:
return;
}
case 'process':
switch ($delta) {
case 0:
return drupal_eval(convert_tokens($text));
default:
return $text;
}
case 'settings':
switch ($delta) {
default:
return;
}
default:
return $text;
}
}
function convert_tokens($text){
$ret = str_replace('%STARTPHP%','<'.'?php',$text); // <- funny concat is there to fool drupal.org's php syntax color-er
$ret = str_replace('%ENDPHP%','?>',$ret);
return $ret;
}
Obviously this code could be optimized ;) (it's just copy/pasted and hacked apart from filter_filter() in filter.module).
Caveats:
- You need to enter your tokens and code in tinymce's html editor window
- You cannot use double-quotes in your code, b/c they are escaped by tinymce (this can probably be changed, though I don't know how)
- Your tokens need to be strings that are not modified by tinymce (i.e. interpreted as text)
- Your code needs to be tinymce-legal as well. I guess you could get really tricky and urlencode it or something ;)
- this is Drupal 5-specific.
TinyMCE removes PHP codes from source.
About problem with eating PHP code by TinyMCE i have found a thread on TinyMCE forum:
http://tinymce.moxiecode.com/punbb/viewtopic.php?id=10778
But it have no answer at now. Maybe later..
codeprotect TinyMCE 3.x plugin protect php code from removing
I have found a codeprotect TinyMCE 3.x plugin that protect php code from removing!
http://sourceforge.net/tracker/index.php?func=detail&aid=1901590&group_i...
how to install this plugin?
Could you please let me know how to install this plugin?
I have:
- extract and place the whole directory (codeprotect) at
modules\tinymce\tinymce\jscripts\tiny_mce\plugins
- edit plugin_reg.php by including this line:
$plugins['codeprotect'] = array();
But it was still not loaded. Thanks.
The plugin works for me
The plugin works for me (after a bit of tinkering).
To get the plugin to work with drupal 6 and tinymce 3.1.1 i had to add a second line to /drupal/sites/all/modules/tinymce/plugin_reg.php to be able to enable the plugin under "admin/settings/tinymce/" Buttons and Plugins
I have done that, and
I have done that, and activated the plugin through the settings page of TinayMCE.
But how do I get the editor to understand PHP-code???
Thanks, it works for me
Thanks, it works for me also.
I have the same issue
And I try to install the plugin codeprotect and still not working.
Any ideas how to solve that? Thank you!
Diego Drigani
-------------------------------
www.codeloper.com
Live from Udine, Italia
-------------------------------
Once you have installed the
Once you have installed the codeprotect plugin you have to enable it from the tineyMCE configuration page
(-->admin/settings/tinymce/edit/all)