blesseld Posted January 29, 2010 Share Posted January 29, 2010 Hey, I have setup a template that will over write content files, there is no database, it a set theme of 15 pages, and I used includes for the content area that get brought into tinymce where you can then use the WYSIWYG editor. I have set variables so you can change themes per page or across all 15 pages. Here is the form echo <<< _END <div class="clear"></div> <form method="post" action="admin-submit-page.php?edit_page=change-theme"> <textarea name="content" cols="98" rows="40"> _END; include ('content-page-change-theme.php'); <--------------------this is the include that sets the variables for which theme should be used echo <<< _END </textarea> <input type="submit" name="SUBMIT" /> </form> _END; then $fp = fopen("content-page-change-theme.php", "w"); if (!$fp) { echo "Couldn't open the data file. Try again later."; exit; } $content = stripslashes($_POST['content']); fwrite($fp, $content); fclose($fp); I FOUND this online and tried it Here is quick and dirty way to add PHP editing capabilities to your TinyMCE. Javascript On the JavaScript side initiate TinyMCE as you normally would, and add setup editor event ( in bold below) <script type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced", theme_advanced_buttons1 : "mybutton,bold,italic,underline", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", plugins : 'inlinepopups', setup : function(ed) { //This event (onBeforeSetContent)gets executed when the setContent method is called //gets executed when the setContent method is called but before the contents gets //serialized and placed in the editor. ed.onBeforeSetContent.add(function(ed, o) { //replace all instances of <?php and ?> with HTML entities o.content = o.content.replace(/<\?/gi, "<?"); o.content = o.content.replace(/\?>/gi, "?>"); }); } }); </script> then on php side PHP On the PHP side take the TinyMCE content and convert the HTML entities back to <?php and ?> $content = str_replace("<?php", "<?php", $content); $content = str_replace("?>", "?>",$content); I tried putting the str_replace in different spots, but I don't think the javascript replaced my php tags, any ideas how i can get this working? Link to comment https://forums.phpfreaks.com/topic/190285-tinymce-trying-to-get-it-to-handle-php-to-set-variables/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.