V
V
Victor2014-11-17 12:20:36
PHP
Victor, 2014-11-17 12:20:36

How to make friends TinyMCE and PHP code?

Hello.
I use TinyMCE and need to type PHP code in the editor (in source mode). The fact is that after switching to visual mode and back, the tags are escaped (something like <--? ?-->). Whether it is possible to bypass it somehow? Ideally, if in visual mode the code was replaced with some kind of icon. Tried the protect setting.
Here I found something similar, but the discussion is old and all the links are broken.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2014-11-17
@v_decadence

tinymce.com/wiki.php/Configuration:protect

M
Max, 2017-07-27
@w_the_h

tinymce.init({ 
    selector:'#editors',
    language: 'ru',
    theme: 'modern',
  plugins: [
    'advlist autolink lists link image charmap print preview hr anchor pagebreak',
    'searchreplace wordcount visualblocks visualchars code fullscreen',
    'insertdatetime media nonbreaking save table contextmenu directionality',
    'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc help'
  ],
  toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code ',
  toolbar2: 'print preview media | forecolor backcolor emoticons | codesample help',
  image_advtab: true,
  protect: [
    /<\?php.*?\?>/g,  // Protect php code
    /<\?.*?\?>/g,  // Protect php code
  ]

Added lines to the Project. I was looking for this topic and everything was not right, I went to the office. documentation:
https://www.tinymce.com/docs/configure/content-fil...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question