Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

SwitchLang Function


  #1  
Old Feb 2, 2010, 04:46 AM
Lyryanne
 
1 posts · Nov 2009
SwitchLang Function

Hi all ^^,

I've a little problem with a function SwitchLang, for my website I have two languages, French and English.

All the pages on my site have the same name in french and english and the only distinction is :
website.com/fr/about/
website.com/en/about/

So I've search on the Internet and I've found this piece of code :

Code:
<?php
function switchLang ($mode) {
	if($mode==="fr"){
	   $posfr = strpos($_SERVER['REDIRECT_URL'],"/fr/");
	   $part1=substr($_SERVER['REDIRECT_URL'],0,$posfr);
	   $part2=substr($_SERVER['REDIRECT_URL'],$posfr+4);
	   $link2=$part1."/en/".$part2;
	   $return="<li><a href=\"".$part1."/fr\">Fr</a></li>";
	   $return.="<li><a href=\"".$link2."\">En</a></li>";
	
 	 } elseif($mode==="en") {
	   $posen = strpos($_SERVER['PHP_SELF'],"/en/");
	   $part1=substr($_SERVER['PHP_SELF'],0,$posen);
	   $part2=substr($_SERVER['PHP_SELF'],$posen+4);
	   $link=$part1."/fr/".$part2;
	   $return="<li><a href=\"".$link."\">Fr</a></li>";
	   $return.="<li><a href=\"".$part1."/en\">En</a></li>"; 
	
	} else {
		$return="<li><a href=\"/fr\">Fr</a></li>";
	    $return.="<li><a href=\"/en\">En</a></li>";

	}

	return $return;
	
}
?>
I've make a switchLang.php file and when I want to make an include in header.php or another file, I've a white page instead of the site.

The other problem is that my flag button for switch is in the $logo_area in the bfa_header_config.php, so when I put the code :
Code:
<a href="<?php echo switchLang(\'fr\'); ?>"><img src="/flag.png"></a>
and when I mouse over the flag I see a link like : website.com/en/about/<?php echo switchLang('fr') ?> so, when I click it, I have a 404.

Can somebody help me to solve this problem?

Regards, Lyryanne =).

PS : Sorry for my poor English I'm French ^^.

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deprecated: Function eregi() when installing theme now mendocinotim New Versions, & Updating 5 Oct 13, 2010 08:04 AM
Call to undefined function the_post_thumbnail() anatta Page & Category Menu Bars 3 Jan 23, 2010 08:47 AM
Call to undefined function the_post_thumbnail() numone Header configuration & styling 5 Jan 20, 2010 06:45 PM
Adding php or function inside content Miak Post-Kicker, -Byline & -Footer 0 Sep 7, 2009 06:50 AM
[SOLVED] Theme's Print Function abroadinspain Post-Kicker, -Byline & -Footer 3 Jul 16, 2009 03:45 PM


All times are GMT -6. The time now is 02:53 PM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.