Jump to content

How to insert google map on a cms page?


Recommended Posts

My Prestashop Version is 1.4.11.0. How to insert google map on a CMS page?. I just want to add some text (phone numbers and addresses) and one map. I tried to do it via tools--->cms--->"Delivery" (Edit)--->HTML button (EDIT HTML SOURCE), but when I paste there the iframe code of the google map and click on Save I see this red message "the field content (Español (Spanish)) is invalid". Please HELP me with this. Please HELP me. I will add here a screenshot.

post-757953-0-62137000-1393646407_thumb.jpg

Link to comment
Share on other sites

it's because default prestashop CMS validate script doesn't allow to use <script> tags

in this case it's necessary to extend validate function (classes/Validate.php)

 

there is a code like:

       	public static function isCleanHtml($html)
        	{
        		$jsEvent = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror';
        		return (!preg_match('/<[ \t\n]*script/i', $html) && !preg_match('/<?.*('.$jsEvent.')[ \t\n]*=/i', $html)  && !preg_match('/.*script\:/i', $html));
        	}   

change it to:

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

there is no other way.

Link to comment
Share on other sites

vekia! thank you very much for your answer. I see this code:

 

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));
}
 
Have I to change it all by this: 
public static function isCleanHtml($html){
return true;
}
 
?
Link to comment
Share on other sites

There is no need to change the code.

 

In Preferences -> General you have as the third option "allow iframes in html fields". If you switch that option to Yes you can insert your Google Map. After you have inserted it you can switch it back to No if you want.

Link to comment
Share on other sites

Thank you again Milos, dziękuję bardzo, and thank you musicmaster. I had already change the code and it is working now, it is working perfectly, the map appears. I couldn't find that third option "allow iframes in html fields" in Preferences -> General.

 

What do you recommend me?, is there any danger due to changing the code?

Link to comment
Share on other sites

in fact, this option is not enough for 1.5.6 due to the fact, that if you want to include google maps script, you have to use <script> and javascript code, these things arent accepted even with <iframe> option is turned on


Thank you again Milos, dziękuję bardzo, and thank you musicmaster. I had already change the code and it is working now, it is working perfectly, the map appears. I couldn't find that third option "allow iframes in html fields" in Preferences -> General.

 

What do you recommend me?, is there any danger due to changing the code?

iframe option is not available in 1.4.x versions, only from ps 1.5.4.x

Link to comment
Share on other sites

×
×
  • Create New...