Tiny Tiny MCE Corrupts PHP tags
altv - July 25, 2008 - 17:31
| Project: | Tiny Tiny MCE |
| Version: | 5.x-1.5 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I'm finding that when I try to include PHP tags in PHP input format on a page node, the TinyMCE module as installed via Tiny Tiny MCE corrupts the PHP tags, and the script fails to work properly.
Example:
<?php
//various code
$url = 'http://';
$url .= $_SERVER['HTTP_HOST'];
$url .= $_SERVER['PHP_SELF'];
If ($List == 'Yes'){
$url .= ('&List=<br>');
}
$sendurl = ('someURL');
$sendurl .= $url;
// echo $sendurl;
?>Becomes:
</p>'); } $sendurl = ('someURL'); $sendurl .= $url; // echo $sendurl; ?></p>
when it is Previewed or Submitted.
I'm not sure if this is a TinyMCE issue, a Drupal issue, or a "Tiny Tiny MCE" issue, but I thought I should bring it to your attention.

#1
Hi Walt,
To enter php code, you should:
- turn off the rich text editor
- enter your code - you need to put <?php at the very start
- save your page
The TinyMCE editor will be disabled until you remove the <?php
I hope this helps.
Steve
#2
Where do I "turn off" the rich text editor?
#3
Under the text area is a link "rich text editor" - click that to turn the editor off. You can then enter your code in the plain text box.
#4
OK, that works within limits. I can at least enter php code that runs server-side before delivering the page. However, I still can't edit the php code afterward. When I return to the edit view for that page, it shows me the TinyURL editor. Clicking the toggle shows me corrupted php code.
#5
if the <?php declaration is the very first thing in the text area (no spaces or anything before), this should disable the tinymce editor. This happens after the page has been saved. Are you using version 6.1.7?
#6
Yes, I just downloaded it a few days ago. Yes, I'm using the <?php declaration with no spaces. There is some regular HTML text before the <?php because I need the code to run after writing something on that page. Are you saying that the only way to use PHP on a page is if there is no HTML code before it within the text area?
#7
I would suggest
<?php /* must be first thing */ ?>...
your html
....
<?php ... your php
The proper fix is for the module to detect the input format - I haven't figured this out, yet. In the meantime you need to "trick" it, as above.
#8
OK, I'll "trick" it for now. Thanks for the tip. Good luck figuring out how to detect the input format. I wish I could suggest something, but I haven't learned enough about how Drupal works to be of much help.
#9
Whups! Something's still not right. I tried your "trick," but after I saved it I went back to try to edit it again, and it came up with the Rich Text Editor turned on, but with no option to turn it off. All the TinyMCE tools were there, and the code was corrupted.
Got another trick I can try instead?
#10
Your setup seems very determined to turn tinymce on! Did you install an older version of tinytinymce and upgrade it? If so it might be worth updating the settings:
- admin/settings/tinytinymce
- reset to defaults
- save settings
I've tried to reproduce this problem but can't see what's happening. Is there a site I could access to see the problem? If not, could I see the HTML source code of one of your pages which has the problem.
Steve
#11
It might also be worth disabling caching of javascript to see if that has an effect.
#12
No, it was a fresh install with the latest version of Drupal 6.3, TinyTinyMCE, and TinyMCE itself. All the latest versions were used with no upgrades, and they were all installed within that past week or so.
If you'd like, I can give you special access so you can try the PHP yourself. Just go to www.mywiz.org and create an account. Once you've done that, I'll give your account the authority to add PHP input format to a page.
#13
Account created as "Steve Lockwood".
#14
Having the same issue here. What was the fix???
#15
I think he's still working on it, because the status of this issue is still active.
#16
Sorry it's taken so long but I can't pin this one down. What I've noticed is that the php tag gets converted to <php These seems to happen in full html and in filtered mode. (I don't have access to the php input format so I can't test that.)
Do you have any other modules or filters active, which might be doing a conversion on the content when it is saved?
#17
I don't really know. Here's a list of the modules I have installed currently. Maybe you can spot something that might be making the difference. I've marked the ones that were installed after I initially filed this bug report with you (so they really can't be causing the problem), as well as those that are not enabled on the main site where you've been testing. By the way, this is a multi-site installation where different subdomains define different sites. I can't think why that might make a difference, but I thought I should point it out.
I have not written any modules of my own, if that's what you were asking. Haven't learned how yet.
Administration Modules
Front Page
CCK Modules
Content
Content Copy
Content Permissions
Fieldgroup
Node Reference
Number
Option Widgets
Text
User Reference
Community Modules
Friend
Core-optional Modules
Aggregator (not enabled)
Blog
Blog API
Book
Color
Comment
Contact
Content translation (not enabled)
Database logging
Forum
Help
Locale (not enabled)
Menu
OpenID
Path
PHP filter
Ping
Poll
Profile
Search
Statistics
Syslog (not enabled)
Taxonomy
Throttle (not enabled)
Tracker
Trigger (not enabled)
Update status
Upload (not enabled)
Filters Modules
Headings anchors (not enabled, added after I initially filed this bug report)
Table of Contents (not enabled, added after I initially filed this bug report)
Flexifilter Module
Flexifilter (not enabled, added after filing bug report)
Other Modules
Account Reminder
Custom Page (not enabled, added after I initially filed this bug report)
Custom Page Admin UI (not enabled, added after I initially filed this bug report)
Diff (not enabled, added after I initially filed this bug report)
Freelinking (not enabled, added after I initially filed this bug report)
Graphstat (not enabled, added after I initially filed this bug report)
Membership
Meta tags
Nice Menus (not enabled, added after I initially filed this bug report)
Nodetype (not enabled, added after I initially filed this bug report)
Talk (not enabled, added after I initially filed this bug report)
Terms of Use (added after I initially filed this bug report)
Tiny Tiny MCE
Wikitools (not enabled, added after I initially filed this bug report)
Stock Modules
Stock API (not enabled, added after I initially filed this bug report)
User goodies Modules
Signatures for forums (not enabled, added after I initially filed this bug report)
User Stats (not enabled, added after I initially filed this bug report)
#18
Thanks for the list of modules - I tried the obvious one (php filter) but no effect! I will carry on looking at this.
Could you also give me a list of the filters allowed, please:
- admin/settings/filters
- click on Full HTML (or whatever format is being used) to see the list of filters
Steve
#19
Just Filtered HTML, Full HTML, and PHP code. I haven't added any of my own. I realized that I hadn't given your role the ability to administer filters, so I've assigned that permission to your role. You should be able to check them out directly yourself now.
#20
I've finally been able to reproduce this problem - working on a fix now.
#21
New release added 6.x-1.8. Hopefully the bug is fixed (in D6 version) - Please reopen the issue if not. Sorry it took so long.
Steve
Please note:
Fix for bug in PHP mode.
If upgrading, it will be necessary to reset the init parameters:
- go to admin/settings/tinytinymce
- click Reset to defaults
2 new features have been added (this was necessary because the fix changes the way textareas are initialised:
- specify textareas for which TinyMCE is allowed but are not initially switched on
- display textarea IDs - as an aid to identification during setup
The new behaviour for this module is:
- by default all textareas are enabled for TinyMCE (with a toggle to turn them off)
- you can list textareas to exclude (TinyMCE not enabled and no way of turning it on)
- you can list textareas to be turned off (with a toggle to turn it on)
To enter PHP code into your textarea:
- turn off the rich text editor using the toggle
- the php declaration (<?php) must be the very first thing in the textarea
- save your node
- the next time you edit, TinyMCE will be turned off
- to re-enable rich text editing, remove the php declaration and save your node
#22
Automatically closed -- issue fixed for two weeks with no activity.
#23
I reopen the bug because I'm seeing it in version 5.x-1.5. Drupal version 5.16.
Steve, in #21 you wrote "fixed in D6 version": do you mean this cannot be fixed on Drupal 5?
If you need access to a D5 site with appropriate permissions, to try and see the bug, I can provide that for you.
Thanks!
#24
I have this problem with Drupal 6.10 and TinyTinymce 6.x-1.12. The only solution I've found is to totally disable TinyTinyMCE while I'm working on PHP scripts. I do this at night, then turn it back on for the office in the a.m.