chuckymendoza Posted February 13 Share Posted February 13 I may have a simple problem, but I can't find a solution, yet. I have a multilanguage Website and like to create a new page via the API with $pages->new The names of my languages are "default" and "english" ("en" in my environment) What I want: set the title of each page the same, in the default and on the English page. I already have set the name identical for both languages with: $happynewyear->set('name', $jahreszahl, 'default'); // set the name for the default language $happynewyear->set('name', $jahreszahl, 'en'); // set the name for the en language And this code works. Problem: this seems not to work with the title of the pages. (Page Title (Multi-Language) is activated When I visit the default site, the title is set correct, but not for the english page. And when I visit the english page first, the title is set correct for the english page, but not for the default page. Am I missing something? Thanks for your help in advance! -Thomas $happynewyear = $pages->new([ 'template' => 'programm_jahre', 'parent' => '/programm/archiv/', 'name' => $jahreszahl ]); $happynewyear->set('name', $jahreszahl, 'default'); // set the name for the default language $happynewyear->set('name', $jahreszahl, 'en'); // set the name for the en language $happynewyear->set('title', $jahreszahl, 'default'); // set the title for the default language $happynewyear->set('title', $jahreszahl, 'en'); // set the title for the en language $lang="english"; // $lang is the language you want to set as active, e.g. 'english' for French $langObj = $languages->get("name=$lang"); // Get the language object for the second language $happynewyear->set("status$langObj", 1); // Set the status of the page's second language to active $happynewyear->save("status$langObj"); // Save the page with the second language status set to active Link to comment Share on other sites More sharing options...
elabx Posted February 13 Share Posted February 13 1 hour ago, chuckymendoza said: $happynewyear->set('name', $jahreszahl, 'default'); Could you try $page->setLanguageValue() instead? Link to comment Share on other sites More sharing options...
chuckymendoza Posted February 14 Author Share Posted February 14 Yes, THANKS A LOT! This gave me the crucial hint! This is the code that worked for me: $happynewyear = $pages->new("template=program_jahre, parent=/programm/archiv/, name=$jahreszahl"); $happynewyear->setOutputFormatting(false); // disable output formatting $happynewyear->of(false); // disable the output formatting API $langObjDE = $languages->get("name=default"); // Get the language object for the default language $langObjEN = $languages->get("name=english"); // Get the language object for the second language $happynewyear->setLanguageValue($langObjDE,'name',$jahreszahl); // set name of page for default language $happynewyear->setLanguageValue($langObjDE,'title',$jahreszahl); // set title of page for default language $happynewyear->setLanguageValue($langObjEN,'name',$jahreszahl); // set name of page for second language $happynewyear->setLanguageValue($langObjEN,'title',$jahreszahl); // set title of page for second language $happynewyear->setLanguageValue($langObjEN,'status',1); // set status of page for second language to active $happynewyear->save(); // save 1 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