Jump to content

User with alternate parent multi language problem


joshua
 Share

Recommended Posts

Hello everyone,

I'm working with ProcessWire now for more than two years and I'm verry verry satisfied with it!

Currently I'm working on a project with integrated "Frontend CRM" and more functions for frontend-user-interaction.

The Contacts for the CRM are Users with an alternate parent (as introduced in 2.5.14). Almost everything is working perfect so, but now I have one Problem:

When a new user is created via the Frontend (via the great PW Api) it's parent has an name like "/en/crm/contacts/maxmustermann/"

In this case the new created contact is only visible, if the Editor has "english" as language actived. In other languages (currently only German) the new Contact isn't shown.

Here's the codepart, where the page is created:

$c_template = $templates->get("contact");
$c_parent = $pages->get(1018);
$c_name = $sanitizer->pageName($c_forname) . $sanitizer->PageName($c_lastname);
if ($pages->get("name=$c_name")) {
   $date = date("ymdhis");
   $c_name = $c_name .$date; 
}

$nc = new Page();
$nc->template = $c_template;
$nc->parent = $c_parent;
$nc->name = $c_name;
$nc->language = $user->language;

$nc->contact_forname = $c_forname;
$nc->contact_lastname = $c_lastname;
$nc->contact_company = $c_company;
$nc->contact_website = $c_website;
$nc->contact_email = $c_email;
$nc->contact_phone = $c_phone;
$nc->contact_street = $c_street;
$nc->contact_plz = $c_plz;
$nc->contact_town = $c_town;
$nc->contact_country = $c_country;
$nc->email = $c_email;

$nc->save();

The input values are validated before this part.

I want the contact to be visible in all languages.

How can I solve this problem?

Many thanks in advance!

Greets,
Josh

Link to comment
Share on other sites

Thanks - I'll check this out now!

@SiNNuT: Of course! ProcessWire is so brilliant and the support forum also is. I haven't found the time until now to answer questions by others but also didn't need any help until today. But even now it is (as always with ProcessWire) a simple & great solution.

Edit: It works!

foreach ($languages as $lang) {
	if($lang->isDefault()) continue;
	$nc->set("status{$lang}", 1);
}
Link to comment
Share on other sites

Welcome @J0sh,

I also know someone who has built a lot of sites (some great ones too) with ProcessWire in the last 2 years. He also hasn't had a forum account here. (Now he has one because he currently has buyed a ProCache agency licence, but his post counter is still saying 0)

And I believe that there are many other out there. :)

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...