loukote Posted September 3, 2018 Share Posted September 3, 2018 Dear forum members, I'm facing the following issue: on a website with multi-language support, there is a template having a multi-language title, ML body and few more fields. The "parent" template looks for pages (news items) using a selector: $pages->get("template=news_entry, sort=-created, Publish_in*=main") The selector does not change with the language. The page (and it's parent) have the multi-language support enabled. The pages (parent getting the pages using the above selector and the "news entry") have the cache disabled and the languages active. Now the problem: a test news entry shows up (selector finds a page) in the default language and one other, it does not show up in two others. The one non-default in which it shows up was installed later. I went through the documentation but I'm blank on what needs to be checked. Would you have any ideas on what needs to be corrected or checked? I would really appreciate! Link to comment Share on other sites More sharing options...
tpr Posted September 3, 2018 Share Posted September 3, 2018 Is Page - Settings tab - Active checkbox checked after page names? Link to comment Share on other sites More sharing options...
loukote Posted September 3, 2018 Author Share Posted September 3, 2018 1 minute ago, tpr said: Is Page - Settings tab - Active checkbox checked after page names? Yes, it is on both - the item and the parent. Link to comment Share on other sites More sharing options...
tpr Posted September 3, 2018 Share Posted September 3, 2018 $pages->get gets only one page, try find() instead. Also, get() ignores published state which is perhaps not what you want. 3 Link to comment Share on other sites More sharing options...
loukote Posted September 6, 2018 Author Share Posted September 6, 2018 On 9/3/2018 at 10:51 PM, tpr said: Also, get() ignores published state which is perhaps not what you want. Sorry, the template used find(), not get(). So it's something else. PW is 3.0.110, upgraded to PW 3.0.111 results in the same behavior. Standard pages work fine. Only the news-list page where subpage are pulled through the api (first $pages->find(), then foreach() ) behaves this way (counts/returns a number of items for some languages and none for others). This is the case whether the field (title, body) is translated or not. is there a way in the api to check whether a page language is active? Link to comment Share on other sites More sharing options...
tpr Posted September 6, 2018 Share Posted September 6, 2018 Use Tracy debugger and dump to see th3 full object. I guess you should post the template file content too to check that also (with the exact data to avoid misunderstandings like the previous get vs find). Link to comment Share on other sites More sharing options...
loukote Posted September 6, 2018 Author Share Posted September 6, 2018 @tpr , thanks for offering help! Which full object? bd($page); ? I'm new to Tracy debugger and do not know how to export the result in a manner that would be readable. The template is as follows: <?php namespace ProcessWire; // basic-page.php template file // Primary content is the page's body copy $content = $page->body; // List all news $section_title = $pages->get('id='.$section_name_id)->title; $limit_news_to_subsites_string = ", Publish_in*=".$section_title; $selector ="template=news_entry, sort=-created" . $limit_news_to_subsites_string; $items = $pages->find( $selector ); $item_nr = 0; foreach($items as $item){ $item_nr++; $news_entry = renderNews($item, $item_nr, true, false, 'full', $user); // Output this piece of news $content .= "<div class='news_entry'>".$news_entry."</div>\n"; } When the language is either French or German, the counter $item_nr==0, for English and Luxembourgish it is ==1 or more, depending on the number of test news items. I tried to activate and deactivate the languages on news/item pages (items to be displayed) and the news page itself (the one that should list them all). No change. The only difference i see is on the admin panel: the languages that return news items do have a drag-and-drop icon and text (lb), not those that return zero news items (de). But this likelu has something to do with the language packs: for FR and DE there is one, for LB there is none. Link to comment Share on other sites More sharing options...
tpr Posted September 6, 2018 Share Posted September 6, 2018 Just bd() what you need to see, eg. bd($section_title); bd($selector); bd($items); and examine what the cause could be. My guess is that there's something with the $section_title, or some news page are still inactive in some languages (de, fr). 1 Link to comment Share on other sites More sharing options...
loukote Posted September 7, 2018 Author Share Posted September 7, 2018 When the page is displayed directly via its own template, languages switch as expected, that is correct title and body are displayed. Only when accessing them through $pages->find( $selector ) the language switching somehow fails. So nothing to see with bd($page->title); On the other hand, Tracy (discovering: it's great!) shows the result of bd($items); (Somehow i do not see a better way to dump it here.) The URL is there but i still need to understand how to display the body and title. So far so good, the family is calling... 1 Link to comment Share on other sites More sharing options...
tpr Posted September 7, 2018 Share Posted September 7, 2018 Is section title translated in your selector? Perhaps its in the default lang all the time. Anyway, you're on the right way, keep searching ? 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