views:

47

answers:

0

Basically, what I need is a way for a PHP script called using ajax to access ExpressionEngine's $LANG superglobal. I'm using ExpressionEngine 1.6.8 core, and jQuery for ajax. My setup is that I have an extension that uses the publish_form_end hook to add some content and javascript to the publish form. The content will be dynamically updated using ajax. For the sake of simplicity, let's say that my javascript looks like this:

 $('#extensionAddedContent').load($('#phpPath').val() + "ajaxBackend.php");

Here, #phpPath is a hidden input, whose value contains the path I need to reach ajaxBackend.php. Let's say that ajaxBackend.php looks like this:

 <?php
 // Needs some way to load the lang file
 global $LANG;
 $LANG->fetch_language_file('myextension');
 print $LANG->line('dynamic_content');

 // end of file

Of course I get the predicted errors, since $LANG doesn't really exist for this script. I try to do it with the following line at the beginning:

require_once($path_to_system . 'core/core.system.php');

since that appears to be the file that prepares all the EE superglobals, but I can't get that to work either.

If I just make it a plain string, with no need for $LANG, it works just fine. But, I want to be able to have everything internationalized, not just the ext.myextension.php file.