Jump to content

Multi Language navigation problem [Solved]


Joss
 Share

Recommended Posts

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

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

  • 1 month later...

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
 Share

  • Recently Browsing   0 members

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