Pitbull Posted January 9, 2014 Share Posted January 9, 2014 hi! i have a question, i have multi language site and i need some way to change the direction when user language is hebrew from right to left - left to right, i try this foreach($languages as $language) { if($language->title == "hebrew"){ echo 'style="direction:RTL"'; } i read a lot of post but i dind find some solution. thank you! Link to comment Share on other sites More sharing options...
RyanJ Posted January 10, 2014 Share Posted January 10, 2014 Is this your full code, cause I do not see where you are echoing $language anywhere? Link to comment Share on other sites More sharing options...
Pitbull Posted January 10, 2014 Author Share Posted January 10, 2014 hi Rjay, i am trying to echo style="direction:RTL" inside body tag if the user language is hebrew <body <?php foreach($languages as $language) { if($language->title == "hebrew"){ echo 'style="direction:RTL"';}?>> something like this? i cant make it work. Link to comment Share on other sites More sharing options...
RyanJ Posted January 10, 2014 Share Posted January 10, 2014 (edited) I am not really sure what you have going on, but your current code does not make any sense to me. Can you show me an example of the site? What are you looping through? Pages? There are better ways I think you could do this, but here it what you are trying to do should look like <?php foreach($languages as $language) { // loop through $languages if($language->title == 'hebrew') { // Now that you have $language, check if its title is == hebrew echo "<body style='direction:rtl;'>"; // if it is, assign it a style } else { echo "<body>"; // if not, echo body with no style. } } ?> Edited January 10, 2014 by RJay Link to comment Share on other sites More sharing options...
apeisa Posted January 10, 2014 Share Posted January 10, 2014 $user->language->name 1 Link to comment Share on other sites More sharing options...
Pitbull Posted January 10, 2014 Author Share Posted January 10, 2014 thank you Apeisa & Rjay.. works fine!! <body <?php if( $user->language->name == 'hebrew' ){ echo "style='direction:rtl;'"; }?>> Link to comment Share on other sites More sharing options...
RyanJ Posted January 10, 2014 Share Posted January 10, 2014 Glad you got it working. I should have re-read your post better paying attention to "user". I also should have realized I was in the Multi-Language Support section. I am glad apeisa picked up my slack and pointed you in the right direction. Link to comment Share on other sites More sharing options...
arjen Posted January 13, 2014 Share Posted January 13, 2014 I recently had to deal with this too. I ended up creating a checkbox field called "rtl" and added it to the "language" template. Now you can easily add a class or hardcode like: <?php if ($user->language->rtl) echo "style='direction:rtl;'"; ?> If you add another language which needs RTL you can just check the "rtl" field and don't have to change the code. 6 Link to comment Share on other sites More sharing options...
apeisa Posted January 15, 2014 Share Posted January 15, 2014 Clever stuff arjen and nice example about PW flexibility. Link to comment Share on other sites More sharing options...
arjen Posted January 15, 2014 Share Posted January 15, 2014 If life was a $page we had less trouble hacking it 3 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