Jump to content

[SOLVED] Problem adding tinymce html editor


Recommended Posts

Hello everyone,

 

After multiple tries to add the tinymce html editor to my cms editor and following these instructions:

 

http://mypresta.eu/en/art/developer/prestashop-product-page-full-rich-editor.html#validate_class_change

 

I dont know what to do, it still isnt working.

 

my prestashop version is 1.5.6.1 default theme

 

I have changed:

 

-classes/validation.php

-admin/themes/default/template/controllers/products/helpers/form/form.tpl

 

Like the instructions and enabled iframes html in BO

 

Can someone send me the adjusted files? or help me further?

 

Thanks in advance,

 

Dennis

 

 

Link to comment
Share on other sites

	public static function isCleanHtml($html, $allow_iframe = false)
{
$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
$events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
$events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
$events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
$events .= '|onselectstart|onstart|onstop';

if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
return false;

if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html))
return false;

return true;
}

Validate.php function isn't correct. you have to change this function to:

public static function isCleanHtml($html, $allow_iframe = false)
{
return true;
}

please follow guide carefully :)

Link to comment
Share on other sites

Hi Guys,

i also tried to insert the code for TinyMCE editor  as descibed in http://mypresta.eu/en/art/know-how/tinymce-editor-full-options-all-html-tags.html, but as i cannot see a change with the editor i must have done something wrong.

 

 

my prestashop version is 1.5.4.1, Theme is elation liquid

 

I have changed:

 

-classes/validation.php

-admin/themes/default/template/controllers/products/helpers/form/form.tpl

 

Can someone send me the adjusted files? or help me further?

 

I realy appreciate your help.

Thanks!

 

 

 

 

 

Validate.php

form.tpl.txt

Link to comment
Share on other sites

validate.php - you forogot to change function:

   public static function isCleanHtml($html)
	{
		$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
		$events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
		$events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
		$events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
		$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
		$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
		$events .= '|onselectstart|onstart|onstop';
		return (!preg_match('/<[ \t\n]*script/ims', $html) && !preg_match('/('.$events.')[ \t\n]*=/ims', $html) && !preg_match('/.*script\:/ims', $html) && !preg_match('/<[ \t\n]*i?frame/ims', $html));
	}

instead of code above use

 

public static function isCleanHtml($html)
{
return true;
}

just follow guide carefully, especially section:

bW7DHmt.png

Link to comment
Share on other sites

  • 3 weeks later...

Hello Vekia,

 

Changed the validate,php file as you mentioned but the tinymce  enriched editor doesnt show up at all in the backoffice. Just the normal small editor.. Have u got another solution? or maybe the adjusted form.tpl and validate.php for default theme?

 

Thanks in advance.

 

Dennis

 

for version 1.5.6.1

Edited by Dennasz1 (see edit history)
Link to comment
Share on other sites

Okay, the editor appears now. Only when i try it sends me to a error page;

 

Property CMS->content is not valid
at line 878 in file classes/ObjectModel.php

 

 

 

Are you familiar with this error?

 

I am trying to link to a javascript file for a photo gallery in the html box

 

Gr,

 

Dennis

Edited by Dennasz1 (see edit history)
Link to comment
Share on other sites

hello

 

you see this message because it's necessary to modify validate class,

by default validate class doesnt allow to use javascripts etc. in text editor, so it's necessary to modify it.

have you modified it as it is described in guide?

 

if so, can you show me modified class? i will inspect it.

Link to comment
Share on other sites

Hello Vekia,

 

It finally works:) i think there was after all just something wrong with the validate file. I download a default validate file and adjusted it again and it works now:) (silly me)

 

Thank you for your patience, i will mark this topic as solved.

 

*I have attached the correct validate file for version 1.5.6.1 in case more people have problems with this. Since i was trying to get it working for quite a time  :lol:

 

Gr

 

Dennis

Validate.php

Link to comment
Share on other sites

×
×
  • Create New...