I've been stuck on this all day and I haven't been able to find an answer that solved my issue:
How can I get this to work? I'm currently working with the PHP in my page--front.tpl.php file because I'm unsure of how to call it.
And I've tried multiple things but none of them worked (so many things that it just got me more and more confused). So therefor my question is just:
Kay Angevare 2015-04-06 03:54:23Z
您应该检查如何先构建模块。这不是使用Drupal 7的好方法7.如果我正在正确读取它，您可以从TPL文件连接到数据库。您只能从模块中进行连接。 Maarten De Block 2015-04-05 18:00:27Z, License: CC BY-SA 3.0
我现在将代码放在.module文件中，并使用测试成功打印出页面上的数组（对任何开发测试的特殊区域设置）。但仍然，我如何制作我在全局中创建的阵列我创建的阵列？ Kay Angevare 2015-04-05 19:49:37Z, License: CC BY-SA 3.0
You should check out how to build a module first. This is not a good way of working with Drupal 7. If I'm reading it correctly, you're connecting to the database from the tpl file. You should only make connections from a module Maarten De Block 2015-04-05 18:00:27Z, License: CC BY-SA 3.0
I've put the code inside a .module file now, and with a test it successfully prints out the array on the page ('ve set up a special area for any developing test). But still, how do I make the arrays I created in my .module file globally available? Kay Angevare 2015-04-05 19:49:37Z, License: CC BY-SA 3.0
There are multiple ways to pass data to JS. Printing JSON encodings in a template file is not a good method.
I recommend Maarten's suggestion at employing a module. Once you've built a module, checkout the documentation on the JS API, specifically the settings section if you're looking to pass module variables to JS.
If you're looking to grab content data (e.g. your nodes have custom geo coordinate fields). You might want to look at the services module; it will let you grab content data in AJAX requests.