0

I posed a similar question a few days back, but perhaps I put the question a bit incorrectly.

I would like my footer.php and sidebar.php to change depending on the URL. If URL contains /ru then show show ru-footer.php else show default footer (footer.php). The same should happen with the sidebar.

If it is possible, could you lead me step by step. Thank you

1

So, this is how I did it and it works.

<?php $url = $_SERVER["REQUEST_URI"];
if (strpos($url, "/ru/"))  {
    $div_id = "logo_top_ru" .$contnet;
}else {
    $div_id = "logo_top_en" .$contnet;
}  
?>
<div id="<?php echo $div_id ?>"></div>

Enjoy

0

If you will really use the URL as switcher then use the predefined variable of PHP $_SERVER. If you are new in the PHP world, use the function var_dump( $_SERVER ); to understand, what is inside the variable on which key for your right solution. Also you can read the fine documentation about the variable: $_SERVER.

0
0

you can simply use the $pagename variable...

$pos = strpos($pagename, "ru");
if ($pos !== false) {
     // ru specific content
} else {
     // default content
}
2
  • Thanks man, much appreciated. I did it a bit differently though... I would write post it, but I cant since I have to wait 8 hours to answer my own question. Still, thanks =)
    – Luka
    Dec 23 '13 at 22:35
  • I tried this out, but it didn't detect the difference between /ru/ and /en/... To clarify, even when I went to /en/ page it still showed the /ru/ content.
    – Luka
    Dec 24 '13 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.