This project is read-only.

Anyone had luck adding a part to User?

Topics: Writing modules
Sep 19, 2011 at 1:26 PM

I have tried adding it in my migration:

ContentDefinitionManager.AlterTypeDefinition("User", builder => builder.WithPart("TimeTrackingPart"));

And I have tried to use the ActivatingFilter

Filters.Add(new ActivatingFilter<TimeTrackingPart>("User"));

I have the part placed, which is usually what burns me when I can't see my shape:

<Place Parts_TimeTracking_Edit="Content:After"/>

And still my driver never get's called for my EditorShape, has anyone had any success doing this?

I'll create a second type and link the user to it with a relationship if I have to, but I'd rather just bolt my part to the user type.

Sep 19, 2011 at 6:51 PM
Edited Sep 19, 2011 at 7:08 PM

Did you install the Profile module?

Try also checking the User Content type if your part was really added (Dashboard->Content->Content types->User).

When I tried to add a part to user  with AlterTypeDefinition, the part was successfully added but the driver wasn't called. When I added my part manually through the Dashbord the driver was called successfully.

Sep 19, 2011 at 8:43 PM

Is that a bug? Because that shouldn't be the case should it? 

I did look at the Profile module, and I looked at the Roles module.

Profiles uses method 1 while Roles uses method 2. Neither has resulted in a call to my driver.


I can confirm it is attached to the User.

Sep 19, 2011 at 8:54 PM

I think the problem is that the user editor is a little too hard-coded. It should be easy to replace it with a more open-minded screen though.

Sep 21, 2011 at 1:40 AM

I have been working on this since yesterday and I have actually gotten this to work.

Looking over the user editor code there was no reason this shouldn't have worked, the controller built the shape of the whole content item so any parts I add should be built. And one part was; the UserRoles part. It was properly rendered.

I really don't know why this solution works or how it's actually different but I got it to work by making the Users module actually define a User type with a UserPart during it's initial migration.

After that, Parts behave as you would expect.