I've been trying to echo html already created by the user (Using TinyMCE) into another page in the application. The problem I keep running into is the tags are echoed into their HTML equivalents (e.g. > instead of <) so they show up on the page instead of effecting the markup.
How do I get CakePHP to display the content as HTML instead of just echoing it?
Try using html_entity_decode.
echo html_entity_decode($theirHTML);
Related
I am currently using ckeditor in my Django project.
setData() in inserting the text as raw html content. Any suggestion how to convert that raw HTML to rich text when setData() us used.
Follwing command is used by me.
CKEDITOR.instances.editor1.setData( "<%- data.description %>" );
Met similar problem in Flask project. In my case, raw HTML tags were transfer to HTML entities, for example, "< p >" is transfer to "<p>", thus the setData did not consider them as HTML tags.
I think you should check the source code of your web page, and to see what is in the setData().
For Flask, the following answer solved my problem:
Passing HTML to template using Flask/Jinja2
I am adding a product attribute onto my product pages in Magento Enterprise V 1.14.1 and I can't get the HTML to display as it should on the frontend. I have WYSIWYG disabled with the 'Allow HTML Tags on Frontend' set to yes and have confirmed in my PHPAdmin databases that it is set to 1, but on my product page it is still displaying the raw HTML.
On the same page I have attributes which point to a static block with HTML and those display as they should, but this attribute which uses a text field doesn't seem to want to display correctly.
This is the code I am using to call my attribute in case that is where the issue is lying where 'static_block' is the name of my attribute I'm trying to call:
<?php echo $this->htmlEscape($_product->getData('static_block')); ?>
And what's weird is when I enable 'Visible on Product View Page on Front-end' and it appears in the 'Additional Information Tab' it displays as it should. So I'm guessing there might be something wrong with my script which is calling the attribute.
Thanks for the help!
It appears to be converting the html into Escaped HTML, which I do not think you want in this case. Try without htmlEscape() wrapping the static_block.
<?php echo $this->$_product->getData('static_block'); ?>
--- 11/10/2014 13:00 EST
It now appears you are calling an array for echo, rather than individual elements of an array.
--- 11/10/2014 13:15 EST
I stripped the HTML, used an HTML cleaner and, using Google Chrome's Edit HTML feature, I stripped out the quoted block and pasted the cleaned HTML and it worked perfectly, which pretty much confirms the Escaped HTML is to blame. It is reading <div> rather than <div> for instance.
echo $this->$_product->getData('static_block');
please use this code
Hi I am developing a html tag based user input, like a rich text box, which saves all the data into a database; including all the html tags.
I then am pulling this data using gridview in asp.net c#.
But when the gridview displays my data, it displays incorrectly.
For example: a user enter his name in bold in the rich textbox as such < b > Superman < /b >, to make it bold. Sadly the gridview displays ecxactly what was entered tags and all without making it bold.
Another example: To enter the name in italics:< i > Superman < /i >, Superman is being display, not in italics.
What I want is for the gridview to display like an HTML PAGE, just like the rich textbox does.
I am using to write question. <-- no idea
Can you help me please?
Thanks
when you bring the html(because that is what you are asking them to enter) back to the view, you are either going to need to transform it yourself or eval the html as is mentioned by #MikeB
alternatively if you are not using Razor try this question for some ideas:
Is there a way to insert Html into a gridview row?
You need to display the raw html. Otherwise it is html encoded to prevent people from being able to run scripts against your site.
You need to be extremely careful displaying user inputted raw html.
If you are using razor it will be something like this:
#Html.Raw(ViewBag.HtmlOutput)
I have this property which is HTML saved from a TinyMCE editor:
<?php echo h($person['Person']['CurriculumVitae']); ?>
How can I have it displayed on the web and rendered as RAW Html not a simple string?
Don't wrap the variable in h(), an alias for htmlspecialchars(), which escapes HTML entities:
<?php echo $person['Person']['CurriculumVitae']; ?>
Just to remove the h() might solve your issue but it will open possible security holes because the field that keeps the html from TinyMCE will now become a possible security hole.
I had the exact same issue and solved it by using http://htmlpurifier.org/ for the output of tinymce HTML. I've written also a CakePHP plugin around it. https://github.com/burzum/HtmlPurifier
HtmlPurifier will allow you to configure an allowed set of Html elements and even of it's attributes. So you could for example specify that href is allowed but class is not.
You'll need to create a config for HtmlPurifier that will match whatever you allow your users to do with TinyMce. It will remove all non allowed tags and attributes from the markup the user has entered.
I am developing site with WordPress and I'm newbie for WordPress. WP adds <p> tag in editor while adding any post or pages. But I can't see the <p> tag in HTML mode. Can anyone suggest me what might be the problem?
Thanks in advance
It's not difficult to do this. To display the p and br tag we just need to install plugin which is "tinymce-advanced" and do some setting change. To change the setting just click check box for "Stop removing the p and br tags when saving and show them in HTML editor" and save. Now we can see the p and br tags in HTML mode.
:)
When you retrieve the stored data from the database, you need to run a filter on it to add the p and br tags back in. This is how wordpress handles content. When you use the_content(), for example, it is already running a filter on it, so when you have a custom loop, you may need to run the filter manually.
<?php echo apply_filters('the_content', $your_retrieved_data); ?>
reference: http://codex.wordpress.org/Function_Reference/apply_filters
You definitely don't need a plugin, and I would recommend not using the method described by user75472. Your data won't be as clean and future-proof.
Try adding the following line just before the_content() tag in your template:
<?php remove_filter ('the_content', 'wpautop'); ?>
Source