Maurizio Fabbri Posted March 1, 2014 Share Posted March 1, 2014 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. Link to comment Share on other sites More sharing options...
vekia Posted March 1, 2014 Share Posted March 1, 2014 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 More sharing options...
Maurizio Fabbri Posted March 1, 2014 Author Share Posted March 1, 2014 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 More sharing options...
musicmaster Posted March 1, 2014 Share Posted March 1, 2014 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 More sharing options...
Maurizio Fabbri Posted March 2, 2014 Author Share Posted March 2, 2014 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 More sharing options...
musicmaster Posted March 2, 2014 Share Posted March 2, 2014 See picture Link to comment Share on other sites More sharing options...
Maurizio Fabbri Posted March 2, 2014 Author Share Posted March 2, 2014 (edited) May be that option is on another version. My Prestashop version is 1.4.11.0. See picture. Edited March 2, 2014 by mauriziofabbri (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted March 2, 2014 Share Posted March 2, 2014 See picture remember that this is 1.4.11 there is no option to turn on "iframes", in addition, google map script requires also <script> tags to run properly. Link to comment Share on other sites More sharing options...
musicmaster Posted March 2, 2014 Share Posted March 2, 2014 I had indeed forgotten that it is 1.4.11. However, I have experience using this with 1.5.6. Link to comment Share on other sites More sharing options...
vekia Posted March 3, 2014 Share Posted March 3, 2014 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 More sharing options...
Maurizio Fabbri Posted March 4, 2014 Author Share Posted March 4, 2014 Thank you very much Milos for clarifying and thank you musicmaster. Excellent support from both. Link to comment Share on other sites More sharing options...
Recommended Posts