Hi

i have a front-page.tpl file that load external php files according to a click on some links.

it works great but one this: it is a multi language site. if i print $language->language on the front page it does change when i switch language. but on the loaded page it is always give me the same language.

so i need to pass the language variable to the external loaded page.

at the top of the external loaded page i have this:

//set the working directory to your drupal root
chdir('/');


//require the bootstrap include
require_once  '/includes/bootstrap.inc';

//load drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

i thought that will give me access to the language variable cause with it i do query the database.

any idea?

Comments

derridaDD’s picture

hi
i separate the front-page.tpl and the external loaded files since they load galleries. and so when the site load it load fast and only when the user press the button for a gallery it will load. and it does work but it is a multilanguage site.

i have tried the global $language and it works inside the tpl files but not in the loaded files.

i tried a different approach and moved one step but now i have another issue:
since the current language is reflected in the url i explode the url and get the language: this seem to work but when i ask for the hebrew images it works and when i switch to english it does not load EVEN though in phpmyadmin the query works fine.

this is the code:

//get the current language
//var_dump($GLOBALS['_SERVER']['HTTP_REFERER']);
$thecurr_url = $GLOBALS['_SERVER']['HTTP_REFERER'];
$currURL = explode('/',$thecurr_url);
//print $currURL[4];

//query section
$category_type = 'gallery_image'; 
$type = 'logos';
$status = 1;
$thelang = $currURL[4];
print $thelang;

$sql = "SELECT DISTINCT n.nid,n.language,field_gallery_image_data,type,title,created,name  
FROM {content_type_gallery_image} 
LEFT JOIN {node} as n ON content_type_gallery_image.nid = n.nid
LEFT JOIN {term_node} ON n.nid = term_node.nid
LEFT JOIN {term_data} ON term_data.tid = term_node.tid
WHERE n.type = '$category_type' AND n.status  = %d AND term_data.name = '%s' AND n.language = '%s' ORDER BY n.created DESC";

$result = db_query_range(db_rewrite_sql($sql),$status,$type,$thelang,0,15);


in the code you can see that i print the $thelang variable and that does change from 'he' to 'en'.

any idea?