Jump to content

Only getting the default language content through Page field


lpa
 Share

Recommended Posts

I have a multi-language site having artist pages with three languages. The content is shown correctly on the artist page.

When I try to refer to those pages through a Page field called artists on an artist list page, I don't get the right language content. 

echo $page->title;

$children = $page->artists;

foreach($children as $c) {
   echo $c->body;
   echo {$user->language->title};
}

The title is shown in the correct language. $user->language->title is show in the correct language. But $c->body is always in the default language.

I don't understand what I am missing. PW version 2.6.5.

Link to comment
Share on other sites

Few things that might be affecting (all from here https://processwire.com/api/multi-language-support/multi-language-fields/#how-language-fields-work).

foreach($page->artists as $c) {
  $c->of(true); // Output formatting needs to be on for multilang
  $user->language = $languages->get("french"); // replace "french" with some langname you have
  echo $c->body;
  echo {$user->language->title};
}

Try above and if it works then you might find the problem. 

  • 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
 Share

  • Recently Browsing   0 members

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