Thursday 6 September 2018

Assigning a default variable in the URL using PHP

I'm new to this forum. I've been browsing the internet for several hours but i couldn't find anything so i hope you guys can help me. I'm building a website with an introductory text in several languages. I've used this: http://www.webgeekly.com/tutorials/jquery/how-to-make-your-site-multilingual-using-xml-and-jquery/ what it does is change content inside divs from an external xml web. It then retrieves the language from the url with typical PHP (which i don't have much idea of): using something like ?lang='eng' The thing is i would like the variable lang to be set to 'eng' by default. It isn't and the text won't load.
Is there a way to assign it in the url or anywhere else? Thank you very much

Update the jquery line:
var language = '<?php echo $sLanguage; ?>';

to read
var language = '<?php echo ((isset($_GET['lang']))?$_GET['lang']:'english') ?>';

that way if they append ?lang=italian, it will use that, and if not assume english.

0 comments:

Post a Comment