swampmusic Posted February 5, 2017 Share Posted February 5, 2017 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. Thx, Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 5, 2017 Share Posted February 5, 2017 I think processwire does always search in the language the user currently does have activated, so you'd probably need to switch through all languages and do a find while each of them is enabled (at least temporarily). Link to comment Share on other sites More sharing options...
swampmusic Posted February 5, 2017 Author Share Posted February 5, 2017 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 More sharing options...
manlio Posted February 21, 2017 Share Posted February 21, 2017 Hi swampmusic, I stumbled in the same problem. I need to use localName($user->language) in a selector. Did you find a solution? Link to comment Share on other sites More sharing options...
swampmusic Posted February 21, 2017 Author Share Posted February 21, 2017 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! 2 Link to comment Share on other sites More sharing options...
manlio Posted February 21, 2017 Share Posted February 21, 2017 Thank you for your reply! 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