Jump to content

How to save page title to other language with API?


Gideon So
 Share

Recommended Posts

Hi,

I have a website with multi-languages support and a frontend form for course registration. If a user choose English which is not the default language, the page title only save to the English tab of the page title.

How can I save the page title to the default language through API??

Gideon

Link to comment
Share on other sites

Hi @Gideon So 

basically you have to switch the user's language like this:

$user->language = $languages->get('en');
$page->setAndSave('title', 'My title');

$user->language = $languages->get('de');
$page->setAndSave('title', 'Mein Titel');

Alternatively, you can use the setLanguageValue() function:

$page->of(false);
$page->title->setLanguageValue($languages->get('en'), 'My title');
$page->title->setLanguageValue($languages->get('de'), 'Mein Titel');
$page->save();

See docs here

  • Like 4
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

×
×
  • Create New...