Joss Posted February 27, 2013 Share Posted February 27, 2013 I am using the multi-language module for processwire. I have set up using example 3 on the documentation page: http://processwire.com/api/multi-language-support/multi-language-fields/#examples And I am looking at the code from example one to sort out my navigation. However, my navigation is in a function (thanks to dear Soma) and I cant get the right values to leap the function barrier. The code I need to run for my menu is: if($user->language->name != 'default') $segment = $user->language->name; else $segment = ''; And then output $segment into my URL. But I am not getting any value out of $segment, so I assume it is not getting $user->language->name from outside of the menu function. What am I missing? Joss Link to comment Share on other sites More sharing options...
ryan Posted February 28, 2013 Share Posted February 28, 2013 It sounds like $user isn't in scope. When you are developing stuff like this, it's good to enable $config->debug=true; in your /site/config.php file. That way, PHP should report notices like this. This is probably what you want: $user = wire('user'); if(!$user->language->isDefault()) $segment = $user->language->name; else $segment = ''; Link to comment Share on other sites More sharing options...
Joss Posted February 28, 2013 Author Share Posted February 28, 2013 Ah, Bon! Merci! I thought about just about everything that was not being grabbed - forgot all about poor little user! Thanks, Ryan, that worked. Link to comment Share on other sites More sharing options...
neildaemond Posted April 19, 2013 Share Posted April 19, 2013 Hey Joss, I was wondering about your experience using this method. Do you know what happens when a user links to an onsite page within their content via tinyMCE text input? does it redirected to the default language verision of the page? 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