Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

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
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 11:55 PM.


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