This project is read-only.

Creating an Own Module only with foreign Moduls...

Topics: Writing modules
Oct 9, 2012 at 2:09 PM
Edited Oct 17, 2012 at 8:07 AM

Hi, I'm new at Orchard, get some Basics but not the total understanding ;)

I guess i just need a hint for the Moment to come forward.

Actually i try to bring Moduls programmatically together (without building a new contenttype manually over the admin/dashboard/contenttype [create new content]) e.g. User, PhoneNumbers, PersonalInformation.

I do not need a new table. Just want to go to the Dashboard and on the AdminMenu (i already done this) have a Link MyOwnUser wich displays User, PhoneNumbers, PersonalInformation

My Question: What minimum files do i need? Modules.txt, Migrations,cs

public int Create() {
        ContentDefinitionManager.AlterTypeDefinition("UserManagement", cfg => cfg
       .WithPart ("PersonalInformationPart")
        .WithPart ("PhoneNumerPart")
      return 1;

How must the View look? Is it possible to display the Foreign-View in my Own Module View?

I not want to extend the UserPart (like in PhoneNumbers)

I read Skywalker, PhoneNumber - but how to Build the Minimum Source for merge different Modules in a new View?



Oct 15, 2012 at 9:02 AM

Maybe my Question is not clear, and I guess the Answer is the '', am i right?

Oct 15, 2012 at 4:34 PM

Not very clear, no, I'm sorry to say. Placement will definitely help reordering the parts to the order you want, but if you elaborate a little on what you are trying to achieve, we can probably help a little more.

Oct 16, 2012 at 11:27 AM
Edited Oct 16, 2012 at 11:28 AM

If you're trying to replicate what the admin screen does when creating content types, the minimum files you'll need are:

- Modules.txt to define the module and make orchard aware of it

- Migrations.cs to create the types and assign parts to it, etc.

- to position the parts in your content types.

And that should be it really,



Oct 16, 2012 at 3:14 PM

Maybe my problem is to easy ;), dont know.

Getting further in  the architecture but not solved it, even when i thought thats it, it dont work.

I git now my own Module, called AdvancedUser, i have a link in the AdminMenu - when i click on it
i want to display (edit) for e.g. AdvancedUser and Orchard.User displaying the AdvancedUser.Create.cshtml
and the User.Create.cshtml.

First i try over Migrations AlterTypeDefinition  .WithPart("UserPart") .WithPart("AdvancedUserPart")

And then (now) over AdminController and Driver (Combine... ContentShape AdvancedUser_Edit User_Edit)

but i do not really know if this is the right approache and i understand the architecture - it's an absolute beginner question ;)
maybe i have to read here for the answer:


Oct 16, 2012 at 4:09 PM

I don't see a question in there, but have you tried the available profile modules? They come with source code...

Oct 16, 2012 at 11:28 PM

the question is, is it easy to combine 2 modules (like e.g. User, PhoneNumber) easy (programmatically as a new module, in the source code) like in the Dashboard (over ContentTypes [create new content]), perhaps my english is to bad that it could be understand what i mean... but still, got no easy solution i believ there is an easy way ;)

Oct 16, 2012 at 11:56 PM

You mean combine two content parts into one type, from code? Yes, but the code for that is pretty much what you wrote in your first post so I'm not sure that really is your question.

Oct 17, 2012 at 8:35 AM
bertrandleroy wrote:

You mean combine two content parts into one type, from code?

yes, thats the question.

combine two content parts into one type (and display them for e.g. User.Create.cshtml and SmtpSettings.cshtml), from code?

Oct 17, 2012 at 9:59 AM
Edited Oct 17, 2012 at 1:10 PM

First mistake from me - i did not realize the Migrations concept, so if UpdateFrom1 is once called i can not edit in UpdateFrom1.

Ok, coming further... know different question ;) - is my problem that UserPart is not Attachable?


Oct 17, 2012 at 5:57 PM

I don;t know: unless I missed it you never said what was failing and how.

Oct 17, 2012 at 6:49 PM

Fail: Making User Attachable

How:  Insert into Orchard.User Migration

        public int UpdateFrom2()
            ContentDefinitionManager.AlterPartDefinition("UserPart", cfg => cfg.Attachable(true));

            return 3;

Question: Now I see can User (UserPart) to a new ContentType, but nothing will be displayed.

          Is it impossible to Add UserPart to a new ContentType (if yes, why) or do i have to do more work to make it possible?

Oct 17, 2012 at 6:50 PM

I'd encourage you to look at the code for existing profile modules.

Oct 17, 2012 at 7:03 PM

Thats what I'm doing the whole day. If I look at e.g. PhoneNumber into the Migrations i found:

                cfg => cfg

After that the PhoneNumberPart is added to the User but the other direction wont work.
Dont know why, but thanks - go further with try and error and looking into existin modules...


Oct 17, 2012 at 9:48 PM

I don't understand what you mean by "the other direction".

Oct 18, 2012 at 11:18 AM

                cfg => cfg

Oct 18, 2012 at 5:53 PM

So that's adding the user part to another content type. What happens when you try?

Oct 18, 2012 at 6:39 PM


even if i add in the Orchard.User Migrations.cs

public int UpdateFrom2()
ContentDefinitionManager.AlterPartDefinition("UserPart", cfg => cfg.Attachable());
return 3;


Oct 18, 2012 at 6:49 PM

Can you elaborate a little bit on the "nothing"? Does a breakpoint in the migration step get hit? Does the part definition get updated in the database? Do you see the part in the content type editor?

Oct 18, 2012 at 8:13 PM

yes, the migration step get hit, the part definition is in the database and i can see the part in the content type editor.

i click in the checkbox and add the part 'User' in the content type editor with for example also title and phonenumber. when i display
my new contenttype i just see the title and the phonenumber - no user, the same like coding it

Oct 18, 2012 at 8:58 PM

Did you try to set a breakpoint in the user part driver?