Google Maps and special Characters problem

9 posts by 2 authors in: Forums > CMS Builder
Last Post: August 23, 2013   (RSS)

By CarlosPinedo - August 22, 2013 - edited: August 22, 2013

Hi, i'm trying to administer a google map with a text field.

But, when I enter this code in the backend:

<iframe width="440" height="306" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=Islas+del+Rosario,+Colombia&amp;aq=0&amp;oq=islas+del+ro&amp;sll=40.396764,-3.713379&amp;sspn=9.082693,21.643066&amp;t=h&amp;ie=UTF8&amp;hq=&amp;hnear=Islas+del+Rosario&amp;ll=10.16356,-75.760517&amp;spn=0.051704,0.075359&amp;z=13&amp;iwloc=A&amp;output=embed"></iframe>
<small></small>

In the frontend the code turns into this:

&lt;iframe width=&quot;440&quot; height=&quot;306&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; src=&quot;https://maps.google.es/maps?f=q&amp;amp;source=s_q&amp;amp;hl=es&amp;amp;geocode=&amp;amp;q=Islas+del+Rosario,+Colombia&amp;amp;aq=0&amp;amp;oq=islas+del+ro&amp;amp;sll=40.396764,-3.713379&amp;amp;sspn=9.082693,21.643066&amp;amp;t=h&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=Islas+del+Rosario&amp;amp;ll=10.16356,-75.760517&amp;amp;spn=0.051704,0.075359&amp;amp;z=13&amp;amp;iwloc=A&amp;amp;output=embed&quot;&gt;&lt;/iframe&gt;<br />&lt;small&gt;&lt;/small&gt;

A lot of characters (<,>",") change, and, obviously the map doesn´t show up.

Is there a way to fix this?

Carlos Pinedo

By gregThomas - August 22, 2013 - edited: August 22, 2013

Hi Carlos,

Are you adding this code directly into a WYSIWYG editor? I think the issue might be that the editor is converting the code so that it appears on the page, as opposed to be run by the browser. To get around this, you need to add the html code into the html editor. To do this press the html button on on the second row of buttons in the editor, then add the iframe code where you want it to appear on the page. I've added a screenshot that shows you how to do this. The button highlighted in green will open the html editor window.

If this isn't the issue, would it be possible to add a post with the PHP that is used to display the code on the page? It could be that you're using a function that converts the code into html such as htmlspecialchars.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

edit_html_001.png 16K

Hi Greg, 

Thanks for answering so fast.

I also think that the issue is that the editor is converting the code so that it appears on the page, as opposed to be run by the browser. But, unfortunately your solution didn´t worked. I wasn´t usig a "wysiwyg" field, i was using a "textfield" field. Anyway, with neither worked

I ´m not using an "htmlspecialchars" function, or anything similar. I need help with this, Greg, this website has a lot of google maps.
.
At this link you can see the issue:

http://www.observatorioirsb.org/cms_googlemaps

this is the code:

<?php header('Content-type: text/html; charset=utf-8'); ?>

<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/observat/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load record from 'ini_info'
list($ini_infoRecords, $ini_infoMetaData) = getRecords(array(
'tableName' => 'ini_info',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$ini_infoRecord = @$ini_infoRecords[0]; // get first record
if (!$ini_infoRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>
<p style="font-family:Arial, Helvetica, sans-serif"><strong>Map Without CMS</strong></p>

<iframe width="440" height="306" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.es/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=Islas+San+Bernardo,+Colombia&amp;aq=&amp;sll=9.719722,-75.782778&amp;sspn=0.091874,0.169086&amp;t=h&amp;g=Islas+San+Bernardo,,+Colombia&amp;ie=UTF8&amp;hq=&amp;hnear=Archipi%C3%A9lago+de+San+Bernardo&amp;ll=9.789757,-75.853901&amp;spn=0.051763,0.075359&amp;z=13&amp;output=embed"></iframe><br /><small></small>
<hr>
<p style="font-family:Arial, Helvetica, sans-serif"><strong>Map using a "textfield" field</strong></p>
<?php echo htmlencode($ini_infoRecord['ini_2_map_izq']) ?>
<hr>
<p style="font-family:Arial, Helvetica, sans-serif"><strong>Map using a "wysiwyg" field (adding the html code into the html editor)</strong></p>
<?php echo htmlencode($ini_infoRecord['ini_2_map_iz']) ?>
<hr>

<p style="font-family:Arial, Helvetica, sans-serif; font-size:26"><strong>Please look at the source code</strong></p>

Hi Carlos, 

I think the issue might be that you're using the htmlencode function, which is a custom CMS Builder function that behaves in a similar way to htmlspecialchars:

http://www.php.net/manual/en/function.htmlspecialchars.php

To get around this modify the code that is being used to display the code to look like this:

<p style="font-family:Arial, Helvetica, sans-serif"><strong>Map using a "textfield" field</strong></p>
<?php echo $ini_infoRecord['ini_2_map_izq']; ?>
<hr>
<p style="font-family:Arial, Helvetica, sans-serif"><strong>Map using a "wysiwyg" field (adding the html code into the html editor)</strong></p>
<?php echo $ini_infoRecord['ini_2_map_iz']; ?>
<hr>

This will stop special characters being converted to their web safe equivalents. 

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Awsome Greg, that was it, thanks a lot.

I have a question regarding a different aspect, I set (By mistake) a field as  "System Field"( restrict field editor access to this field). How can this action be undone?

Carlos Pinedo

Hi Carlos,

You can do this fairly easily. While logged into CMS Builder, if you go to section editors area, then click the modify link on the section you need to edit. This will bring you to a page that shows all of the fields in a section. If you click modify on the field that you've accidentally made a system field. This will bring a up a pop up box where you can edit all of the details for the field. At the bottom of the dialog box is area called advanced, which has a checkbox to decide if a field is a system field or not. You edit this for any field except the num field. 

I've attached a screen shot that should hopefully make things clearer.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

system_field.png 17K

Hi Greg,

Actually, the problem is that the "modify link" disappeared after I accidentally set those fields as "System" fields. I'm attaching an image of this problem.

Carlos

Thanks a lot Greg! problem solved.

Carlos