This project is read-only.

Make Chapter a Container

Topics: Customizing Orchard, Troubleshooting
Apr 15, 2011 at 4:51 AM

I'm using the Chapter module to create some books/chapters etc

For a particular book named "Test" I want each chapter to be a list. So I went to the Content Types and selected "Test Chapter" and added the Container part.

When I create a list item however, there is no option to add the item to the chapter.

I'm not sure if I'm missing something obvious?


What I want is:

A book containing chapters. Each chapter contains a list of items.

Apr 15, 2011 at 5:43 AM

List is a content type that is a container, but not any type with a container is a list.

Apr 15, 2011 at 5:55 AM

Ok. So I can create a content type that contains a "Container". And then if I create an item from that content type, I can add my items into it, although it isn't specifically a list.

But if I edit the Chapter content type to have a "Container", I can't add my containable items.



Is there a way to make a chapter have a list/container or something so that I can add/associate items with a chapter?

Apr 15, 2011 at 6:07 AM

Chapter, like Blog, has its own custom logic about what it can contain and how you create that stuff. Why not create your own Chapter type?

Apr 15, 2011 at 6:37 AM

Ok, so to confirm. I will need to write a custom Chapter module? It's not possible to set it up via the Admin screens?

I'd hoped the chapter type would let me add custom parts without having to edit the module code.

Apr 15, 2011 at 6:52 AM

I don't know: you never said what you wanted to put under your chapters. Why not adapt pages to your needs for example? I don't know enough about your scenario to give advice.

Apr 15, 2011 at 7:18 AM

After restarting the website and redoing some of the steps it all works. It seems there was some caching issue that was stopping me from being able to add items.


I'll try to explain what I want to do (which now works, but only after restarting the website).

Created a book using the Chapters module named "MyBook".
Created two chapters under the book: "MyChapter1", "MyChapter2".
When I created the book, the "MyBook Chapter" Content Type was automatically created for me (by the Chapters module I assume).
I then edited the "MyBook Chapter" type and added the "Container" part.

I created a content type named "MyEntry" and added the "Body", "Common" & "Containable" parts to it.

What I expected after this was that I would be able to create a new "MyEntry" item and the "Add to" dropdown would display the chapter, so I could then add the new item to the chapter. This step didn't work. Nothing was displayed in the dropdown list except for (None). However, after I restarted the site this was now populated with my chapters and I can successfully add the entries.