0

I need to use Php Filter with ckeditor. Problem is that Ckeditor change this:

<?php echo "hello";?>

to

<p>&lt;?php echo "hello";?&gt;</p>

How can I solve this?

I already added this:

config.allowedContent = true;

under Custom JavaScript configuration at: admin/config/content/ckeditor/edit/Full

But it didn't help.

I also make sure I checked Php evaluator under Enabled filters at admin/config/content/formats/full_html

  • 2
    I strongly suggest you to reconsider. PHP filter is really asking for trouble. In pure CKEditor you would use sth like CKEDITOR.config.protectedSource.push( /<\?[\s\S]*?\?>/g ); I don't approve doing it, but should work. Don't know how to wrap it in Drupal. – Mołot May 14 '15 at 11:26
  • I know, but I need to insert a custom view block and this module is not working for me: drupal.org/project/insert_view I already posted my issue (drupal.org/node/2488534) but I get no help so far. Then the only way I see is using php. – chefnelone May 15 '15 at 7:20
2

Change the 'insertElement' function for 'insertHtml' function

editor.addCommand('phpcode', {
  exec : function() {
    editor.insertHtml('<div id="phpcode"><?php echo "hello"; ?></div>');
  }
});

Hope it will be work.

0

In /admin/config/content/formats/full_html try unchecking the Correct faulty and chopped off HTML box. Maybe it thinks your php is html.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.