Jump to content

Selectors, Multilingual, UrlSegment & localName


Recommended Posts

Is it possible to use localName($user->language) in a selector, something along the idea below, but I can't get it working ?

$pages->find("template=hotel, localName($user->language)=$input->urlSegment2");

The problem I have is a urlSegment2 in any of 3 languages, so I need to be able to find the page in different language "names/urls".

I dont like the idea of looping thru all the hotels looking for $hotel->localName($user->language) = urlSegment2;

But I can't seem to figure out how to make a Selector work based on current language rather than the default.


Link to comment
Share on other sites

Thx for response :-)

It's strange, the "name" field seems to be treated differently. For example, where english is the default language, when switching to french the following works ok :-

$hotel->title   ..... is in french

$hotel->description ..... is in french

But, $hotel->name remains always in english unless you specifically define localName method - which I can't figure out how to do in a selector.

Therefore, I am not so sure about selectors working on "name" field when you need to test it in anything other that the default language. I guess that's what I need to know, if they can do it, otherwise I have a problem. Looping thru a possibly very large dataset doesn't sound good.


Link to comment
Share on other sites

  • 3 weeks later...

No sorry, I had to do a dirty workaround that meant looping thru records. Nothing elegant and it's a concern for me moving forward if I have very large datasets.

I got into a  real mess with urlSegments and then having to build the Url for both the languageSwitcher and also the Breadcrumbs in a _main.php.

Honestly, Processwire is a really smart piece of code ( i'm very new to it ), but in all my experience coding, when things go this wrong, it's normally because I am not doing something correctly, or I have badly thought it through.

I will return to it in a little while as I need to make head way on other parts of the site. If I find something that works better, then for sure, I'll let post it here.

Good luck!






  • Like 2
Link to comment
Share on other sites

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...