Hi all,
I have searched for this pretty much everywhere, and I know the answer should be obvious but I can’t find it.
I have a PHP snippet that outputs a piece of javascript code.
When I ran the snippet as is, everything worked, except for where the multi-dimensional array had [[ .... ]] That would get replaced by nothing (I am assuming that the template parser was doing it’s job there.)
I tried loading it in to a TV, and outputing it that way. Same thing happened. Is there any way that I can output this information so that it works properly? (this is dynamically produced information so I can’t just take the output and stick it in a .js file)
Output from Modx:
var data = {"zoom":15,"garages":[{"id":"1","name":"Akatiff Lot","address":"N. Autumn Street North of Julian Street","phone":"(408) 295-7275","hours":"Open for arena events","rates":"Rates vary by event","discounts":"","directions_link":"
http://maps.google.com/maps?q=N.+Autumn+Street+and+Julian+Street,+san+jose,+ca&spn=0.025608369289529875,0.028457164764404297&hl=en","points":}
It is the points location that is the issue.
What it is supposed to look like:
var data = {"zoom":15,"garages":[{"id":"1","name":"Akatiff Lot","address":"N. Autumn Street North of Julian Street","phone":"(408) 794-1090","hours":"Open for arena events","rates":"Rates vary by event ($10-$20)","discounts":"","directions_link":"
http://maps.google.com/maps?q=N.+Autumn+Street+and+Julian+Street,+san+jose,+ca&spn=0.025608369289529875,0.028457164764404297&hl=en","points":[[37.33830,-121.90116],[37.33867,-121.90134],[37.33853,-121.90189],[37.33826,-121.90262],[37.33775,-121.90408],[37.33632,-121.90245],[37.33693,-121.90151],[37.33676,-121.90129],[37.33656,-121.90108],[37.33693,-121.90048],[37.33785,-121.90134],[37.33802,-121.90099]]}]};
The code that produces the above:
ob_start();
?>
<script language="JavaScript">
<!--
var data = <?php print_data($modx,$zoom); ?>;
var poiLocations = [ null // 1-indexed.
{foreach from=$points_of_interest item=p}
, new GLatLng({$p->lat}, {$p->lng})
{/foreach}
];
//-->
</script>
<?php
$output=ob_get_contents();
ob_end_clean();
$modx->setPlaceholder(’parking_data’,$output);
I have tried simply echoing $output as well and still get the same thing.
Template call:
[[parking_display? &zoom=`15`]]
[+parking_data+]
Any suggestions?
Thanks,
Bryan