Zeka Posted November 11, 2016 Share Posted November 11, 2016 Hi. I have this structure of page page -- repeater field --- page select field -- repeater field --- page select field etc I'm looking for better way to detect is there at least one page in page select field in all repeaters that available for current language. $currentLang = $user->language; $repeater_items = $page->repeater_field; $groupHasLang = 0; foreach($repeater_items as $ri) { if($ri->page_select_field->getLanguages()->has($currentLang)) { $groupHasLang++; break; } } if($groupHasLang) { // do something } Maybe it could be accomplished just with find method? Thank for any suggestions! Link to comment Share on other sites More sharing options...
BitPoet Posted November 11, 2016 Share Posted November 11, 2016 Have you tried doing if($page->repeater_field->find("pagefield.status=on") ) { // ...whatever... } ? (untested) Link to comment Share on other sites More sharing options...
Zeka Posted November 11, 2016 Author Share Posted November 11, 2016 @BitPoet Thank you for suggetion. You pointed me to the right direction. In this way it works only for non-default language ( becaouse there are status table for default language in db and status____ for non-default langauges where ____ is id of langauge ). $currentLang = $user->language; $repeater_items->find("menu_item_page.status$currentLang=1"); I tried to use OR group to cover default langauge $currentLang = $user->language; $repeater_items->find("(menu_item_page.status$currentLang=1), (menu_item_page.status=1)"); It looks like needed pages were found but they are in itemsRemoved array ( I see it first time, so I don't know what is it ). 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