I just started using Drupal and it is a great system :)

I have installed the FCKEditor module. I am having trouble trying to create a page with PHP code. I am doing this to try and create a form for the form_mail module.

When I insert the php code I am using the following steps:

1. Using the source edit in the FCKEditor
2. putting the php code in with the tags
3. the input format is being set to PHP code
4. Pressing submit

The

 tag is being changed to <!--p
and the 

tag is being changed to -->

Has anyone ever seen this before, or know what I need to do to get the problem resolved?

Thanks,

Paul Zepernick

Comments

zepernick’s picture

I disabled the FCKEditor module added the php page and then re-enabled. It seems to be working ok...I have not actually tried to submit the form yet.

I would be happy to get any suggestions on how to avoid this from happening.

- Paul

GN’s picture

FCKeditor is often too obtrusive, and meddles with the codes that you are trying to insert. It is especially bothering when it interferes with administrative settings.
As for me, the simplest solution is switching to TinyMCE, whose behavior is much more modest :-)).

rayvee’s picture

This is actually very simple.
When you type in the fckeditor in source mode for example this code:

When you switch from source to online editor and back to source mode, Fckeditor will magically change this to:

<!--p-->

But this is actually no problem since the trick is to put your php code where the "p" is. You just replace the "p" with your php code. That is it. Your code will be saved without ever being changed again.

The reason Fckeditor changes the code IMHO is for the fckeditor html parser not to try to parse the php code and come up with some errors. (If I am wrong please correct)

But with this trick people that need to mix HTML and php together and update the html on a daily basis will not have any problems anymore if you use this method. Its permanent and not temporary. And you dont need to disable the fckeditor first. You can do this directly in source code mode.

Hope this helps a lot of people out. I wrestled with this problem myself for quite some time and search the whole internet without finding the answer. It was actually just something I said I am going to try and it worked. Most of the time the answer is easier than one thinks.

Rayvee.

Think outside of the Drupal
http://www.cybergateinteractive.com

canen’s picture

you may want to change to source view in the editor since the editor will convert everything to html before posting, regardless of what filter is set.

This is the way it worked with tinymce and htmleditor, i haven't used fckeditor though.

zepernick’s picture

Thanks for the tip. However, I am already in the source view when this is happening.

Paul

jczapla’s picture

I decided that FCKEditor will not be available for page type content.
FCKEditor will works only with story and other content type (acidfree for example).
In fckeditor_form_alter($form_id, &$form_values) (in fckeditor.module) I added condition witch checks content type.

function fckeditor_form_alter($form_id, &$form_values) {

	if(strpos(strtolower($_SERVER['QUERY_STRING']), 'page'))
		return;	

...

So I can create php content without wysiwyg editor as page content and html content with fckeditor (html with forms for example).

Is it stupid? I hope not much.

Andrei Toutoukine’s picture

Q: What's the use of WYSIWY(n)G?
A: To help non-HTML-professionals in editing the content

Q: Who is responsible for PHP-driven content?
A: Professional programmer.

I created a special role named 'programmer' and disabled the FCKEditor for them.

With the best regards,
Andrei

shixi’s picture

enable this line in modules/fckeditor/lib/fckconfig.js:

FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ;    
a.a.egoroff’s picture

Worked for me!
But I also type additional line:

FCKConfig.ProtectedSource.Add( /<\?php[\s\S]*?\?>/g ) ;
vacilando’s picture

7 years later, same problem (with latest WYSIWYG and CKEditor). See also #1403918: "<?php" replaced by "<!--?php" by CKEditor