DB content not coming into tinyMCE textarea - php

My tinyMCE editor is showing up just fine, but in the form I have a select box and according to what you choose, the textarea is filled with content accordingly.
Like if I choose PHP, then the description for PHP comes into the textarea. It works without tinyMCE, but when I add tinyMCE, nothing shows up in the textarea.

TinyMCE does not display the content of the textarea in real-time. It reads the content on start, and saves it at the end of the work. All the edit work takes place in an iframe element, created on the fly by Tiny. If you update the textarea, you must ask TinyMCE to refresh itself.
In a few minutes I will look up the exact method for you. (It was long time ago when I was using TinyMCE, so I forgot the method names.)
[few minutes have passed..]
Look at the documentation: http://www.tinymce.com/wiki.php/How-to_load/save_with_Ajax_in_TinyMCE
You just need to call setContent method on the TinyMCE editor, instead of (or in addition to) setting the new text in the textarea.

with tiny mce sometimes it dependes the plugins that you in the Init.
Try Removing all the plugins and add one by one and see if this helps you in finding a better solution for this.
Some plugins like the media can strip and not allow tags in the text area, so the textarea is empty if tiny mce doens't allow that tags, or add valid_elemens:'[]' and try if it shows something.
Good luck

Related

wordpress deletes <sup> on save comment

I'm trying to implement an WYSIWYG editor to my WP comment section. I experience many difficulties with saving the HTML data in the WordPress database. WP strips many of the HTML tags automatically. I was able to restore the tags trough the 'preprocess_comment' filter. I added the wpautop() filter to the content. Now the line breaks are appearing. But when I want to use the tag, WordPress deletes is too.
I use the Trumbowysiwyg js solution to replace the default comment textarea with the wysiwyg editor. When using the editor, the HTML code looks nice. It has all the HTML tags but after saving the comment, these tags are stripped. Can someone tell me how to allow HTML comments to be saved in the database?
WordPress keeps a list of allowed tags which you can use in comments, surely you do not want users to post any html they want. So I suggest you edit the allowedtags so they will not be removed.
add_action('comment_post', 'allow_more_tags');
function allow_more_tags() {
global $allowedtags;
$allwedtags['sup'] = array('class'=>array());
}
Like this you can add any tags you like and even allow certain classs to be added to them.

wordpress page.php styling and markup

I have a couple of questions related to building a custom theme with Wordpress.
1) If the website is made up of pages, I can use page .php to run the LOOP and retrieve content. In this case, is it OK to paste the content (of each page) using the backend of word press - I.e. paste all content and HTML markup into the 'text; . Is this a reliable way to enter content and accompanying markup into the database?
I guess the advantage is that users will then be able to edit the content themselves using the visual Tab.
Many thanks,
P
Well this not a recommended way to do it, but yes the editor is there for the same purpose. I wont be using it this way, because in my experience wordpress editor often acts weird with html. By default auto paragraphs are enabled, so everything gets in its own paragraph, even if you disable auto paragraph it still has some issues. For instance if you add html in the text tab, and then goto visual tab and switch back to html, and save the same html, this time it would be styled differently. Secondly its also not good to allow users to add html from a security POV and you cant guarentee the consitency of the website.
I would recommend using custom fields instead and fetch these custom fields in the through your theme files.

Wordpress,how can I convert textareas to use a wysiwyg editor?

I have a question about wordpress. I am creating a web form for branch managers to enter data into a database, one of the fields can contain bullet points so I need to use an editor that will allow the user to use bullets and then convert it to html like the way wordpress handles posts. Is there a way to make text areas use the tinymce editor? I tried using mceTextarea but it didn't do anything. Anyone know how to add editor options to textareas?
(Making this an answer so others can find it.)
WordPress has a function called wp_editor() that creates a WYSIWYG editor anywhere you need one.

How can I insert XML example code inside a Joomla article?

I'm building a site in Joomla 2.5 that covers topics related to programming.
I have tried various plugins and I had no problem to insert java, javascript and php code inside my articles (the classic view with indented line number)
The problem arises when I try to insert XML.
Currently I'm using the plugin Code HighLight (but I found the same thing with other plugins).
To insert the XML code in my article I have to do so in my article:
{code class="brush: xml;"}CODE HERE{/code}
The problem is that, if I insert Java or Js or php code I have no problem, but if I try to insert XML code in this way in my article it appears bad (parts missing)
I also tried to plug it directly into HTML (by pressing the button HTML editor TinyMCE) but, once inserted, when I come back to the WYSIWING editor, this problem occurs again.
In the plugin instruction I can read:
BEWARE of your visual editor (JCE or JCK for example), it can place tags in your code, after this code became invalid!
I use TinyMCE as editor (it is always a WYSIWYG editor) and seems that this is the problem infact if I disable the graphical editor (inside the Joomla global configuration setting the editor as void) or if I choose the CodeMirror editor (that it is a simple HTML editor, not a WYSIWING editor) if I insert the XML code in te previus way...work well !!!
The problem is that I need a graphical editor (to set the styile of my articles text) and at the same time I need to insert XML code snippet inside my articles...
I have observed that behavior using many code snippet plugin...the problem is not a plugin problem but I think it is related to the WYSIWING editor that seems to insert it's tag inside the XML code or at least makes it dirty (eliminates parts and inserts some tags like )
What can I do to have XML code snippet in my articles and at the same time have a WYSIWING editor? (if the problem is TinyMCE I can also try some other WYSIWING editor...)
Thanks
Andrea
You can give extension for code display a try.
Another solution I read about was
1) activate Content - Code Highlighter (GeSHi)
2) generate your code here
3) C&P the generated code in the WYSIWYG editor
You can do either one or the other...you cannot do both.
My suggestion is this: do the WYSIWYG part of the page...toggle the WYSIWYG editor off...then insert your xml...and NEVER go back to that page with the WYSIWYG editor on again.
I have had the same issues inserting xml in my website.
If you have logged out of joomla and log back in...the default is the WYSIWYG editor.
So if you open an article/module/plugin and it opens in WYSIWYG, it clears the xml that you have inserted into the page. Simply toggle the WYSIWYG editor so that it is off...then CLOSE the article (DO NOT SAVE & CLOSE)...just close. Then open the article/module/plugin again...it should be the html editor only...and code away.
I hope this helps.

WordPress - PHP Code Box

I am very new to WordPress, so I would appreciate some help.
I am using WordPress as a CMS, and I am trying to make the thing work so that when I select a page to edit, there is a special box where I can input PHP code that will execute on my page.
I have found the PHP exec plugin, which works perfectly, but I would like to keep the code out of my main text editor, out of the way of my client's careless fingers.
Any suggestions would be very, very appreciated. Thanks!
You could create a template for each one, and include your PHP there.
Simply select the template from the page edit page.
But if you are only including a little PHP per page, you could get the slug via WordPress in your page template and act on it accordingly.
You can also add an extra meta box on the post editor page, only visible to you, with a textarea where you can add the code. You would save it as a meta field of the post. Your template can check for the existence of this field, and execute it if found.
PHP Exec is the best plugin I have found, and I looked long and hard for that one. The problem with doing it as you suggest is that if the PHP code displays an item on the page, it still has to be formatted within the page as well. It is a simple logistical problem, but somewhat of a complex coding problem. I haven't been able to get around to working on creating a better plugin for it.

Categories