When I enter save html through ckeditor I miss tag from the html content. Is there any ckeditor configuration I have to do to allow html tags such as inside html content? Thanks.
You have to use the allowedContent property when instantiating ckeditor to allow specific tags, or allowedContent: true to allow everything
https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-allowedContent
Either using config.js, or in-page configuration for the specified textarea:
https://docs.ckeditor.com/ckeditor4/latest/guide/dev_configuration.html
In my case (I am using a Symfony ckeditor bundle) I also can set it via bundle configuration inside config.yml.
Related
I am a newbie to PHP Symfony and Twig. I need to dynamically set meta property og:image from the post content, if there is an image. I have a twig code like this.
<div class="content">
{{ d.description|raw }}
</div>
I can and get an image url from the div content if any and set it as a meta property og:image by using javascript but Facebook does not parse JavaScript? Is there a way to do this on server side?
Facebook indeed only reads the source code of the page, so you won't be able to js your way out of it, you have to rely on server side.
You'd have to process the content, in the controller, by using a DOM parser (you can use PHP's own DOMDocument class https://www.php.net/manual/en/class.domdocument.php) and search for an img node (or lack thereof, in case you'll need to provide a default value)
Once you have found the url of the src of the image (user provided or default), pass this as a variable to the view and echo it inside the appropriate meta tag.
Do not forget to print the full path of the image, including the domain and protocol as Facebook now requires it.
I'm trying to use OpenTBS on my project to generate automatically a Resume using a word template (.docx)
the template contains multiple images for the frame of the template.
when I try to generate the file with my data, i noticed with the debug option that the opening tags disappear when I use block=tbs:row inside.
here is my php code :
$domains=array(
array('id1'=>"xxx",'id2'=>"xxx"),
array('id1'=>"yyyy",'id2'=>"yyyy"),
//...
);
$tbs->LoadTemplate('mytemplate.docx', OPENTBS_ALREADY_UTF8);
$tbs->MergeBlock('domain', $domains);
on my docx side :
[domain.id1;block=tbs:row] :
[domain.id2]
these tags are inside a table which is inside a textbox.
after 2 days debugging I realized that some opening textbox tags disappear on generation causing an xml parsing error opening the document
edit : After some other tests, it's when I use the block tag inside a textbox that the bug appears.
thanks for your help.
Matt.
I am using CK Editor 4.5 as text editor in my form.
I have pasted my html code including "style" tags to the editor. But when saving the data it automatically removes the style tags from the code.
I have tried to turn off Automatic Content Filtering by add this to config file
config.allowedContent = true;
But it still remove the style tags. The editor also removes the text color, text align styles added.
How can i add style tags using CK Editor.?
My apologies. Its not the issue of ckeditor.
I am using codeigniter for server scripts. It removes inline style on form submit.
I'm using Rails and met the same issue, it turns out that I'm using sanitize to render content, which will remove the inline styles.
I am using ckeditor for codeigniter project, when i try to add span tags it's getting replaced with p tag.
Is there any way to add span tag using ckeditor?
Do you have XSS filter turned on in the config file? It removes some "illegal" tags from your POST input.
Try this
I'm trying to use CKEditor to input rich text into my database, which works except the formatting is not the same when I try to output the rich text the user entered. The position of elements such as pictures is incorrect.
I currently have the following code:
Input:
$pitch = htmlspecialchars($_POST['editor1']);
$sql = mysql_query("UPDATE projects SET pitch='$pitch' WHERE id='$proj_id'");
Output:
$pitch = htmlspecialchars_decode(stripslashes($pitch));
The result is then echoed back which creates the incorrect formatting.
Does anyone know what I'm doing wrong?
This has nothing to do with PHP.
Contents of the framed editor (which you use) is styled by the contents.css file which you can find in the main CKEditor directory. However, this stylesheet is not used on your page, so content created in editor is not styled by the same rules.
The correct approach is - style content on your site and then copy (or somehow reuse, e.g. by setting config.bodyClass and config.contentsCss) these styles in editor contents.
Remember, that you also need to set styles available in styles drop down. They are by default configured as for the sample, but when you'll change available styles, you need to update styles.js file too.