mds Posted January 5, 2017 Share Posted January 5, 2017 I have a website in two languages: nl and en, using the Languages and AutoDetect Languages modules for it. There are two links on the page that lead to an external website which needs a lang parameter in the url "https://www.example.com/accounts/create/?lang=nl". The strange thing is that on the live website in Dutch (nl) the lang parameter is changed to 'en'. In English it's the other way around. <?php echo "<a class='login' href='https://example.com/accounts/create/?lang=" . "$hreflang" . "&?utm_source=corporate_site&utm_medium=redirect&utm_campaign=redirect-corporate_site-start'>" ?> I have also put the url without $hreflang (href="https//example.com/accounts/create/?lang=nl&?utm_source=corporate_site…") in a textarea field and it is also changed. The $hreflang is defined before <?php // handle output of 'hreflang' link tags for multi-language // this is good to do for SEO in helping search engines understand // what languages your site is presented in foreach($languages as $language) { // if this page is not viewable in the language, skip it if(!$page->viewable($language)) continue; // get the http URL for this page in the given language $url = $page->localHttpUrl($language); // hreflang code for language uses language name from homepage $hreflang = $homepage->getLanguageValue($language, 'name'); // output the <link> tag: note that this assumes your language names are the same as required by hreflang. echo "\n\t<link rel='alternate' hreflang='$hreflang' href='$url' />"; } And after that mention in the php-file <?php foreach($languages as $language) { if(!$page->viewable($language)) continue; // is page viewable in this language? if($language->id == $user->language->id) { echo ""; } else { $url = $page->localUrl($language); $hreflang = $homepage->getLanguageValue($language, 'name'); echo "<a hreflang='$hreflang' class='languagetoggle' href='$url'>$language->title</a"; } } ?> </nav> Link to comment Share on other sites More sharing options...
Harmen Posted January 5, 2017 Share Posted January 5, 2017 Hi, The following code works for me: foreach($languages as $language) { $selected = ''; // if this page isn't viewable (active) for the language, skip it if(!$page->viewable($language)) continue; // determine the "local" URL for this language $url = $page->localUrl($language); // if language is current user's language, make it selected if($user->language->id == $language->id) { $url = "#"; $selected = " class='current'"; } // output the option tag echo "<li$selected><a href='$url'><span>$language->title</span></a></li>"; } Hope this works for you too -Harmen 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now