Jump to content

Recommended Posts

Posted

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

Posted

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 = ''; 
Posted

Ah, Bon! Merci!

I thought about just about everything that was not being grabbed - forgot all about poor little user!
 

Thanks, Ryan, that worked.

  • 1 month later...
Posted

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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...