Creating containers linked to node types

We've now got all the node types we need for our site. There's the built-in containeri type for creating all of our containers, which will be topics, moods, and people. We've got the built-in categoryi type for creating all of the categories for topics and for moods. And we've got our new person CCK type, for creating the categories that will go in people. Let's continue by creating our three containers.

Navigate to your create content -> container page. We'll start with the topics container, so enter topics as the title, and something like select one or more topics as the help text. Tick the story checkbox for types, and tick multiple select. In the category display settings box, set show prev, next, and up links and display TOC within this container to enabled. Also tick the check boxes for show assigned nodei count in TOC, show links to categories on assigned nodes, and show message if no posts. For the category menu settings box, set menu items within this container to enabled. The rest of the settings can be left at their defaults, or you can play around with them if you wish (you should know what you're doing by now). Submit your new container.

Creating the topics container
The topics container will hold categories that can be assigned to story nodes.

Next, we're going to create the moods container. There's no need to go through this step-by-step, as it can have almost exactly the same settings as we gave the topics container; except that it will have free tagging ticked instead of multiple select. Enter all the details, and submit this container.

Only one container to go: the people container. Once again, this will have almost exactly the same settings as the topics container (the people container will also be multiple select, rather than free tagging), so enter in all those details, and then hit submit. That was quick! Three containers in three minutes - guaranteed, or your money back. Call in the next ten minutes, and we'll throw in a brand new [container to hold categories of various models of] Ferrari, absolutely free.

OK - now that we're through the preliminary tasks, let's move on to the fun stuff. But first, let's have a look at what we've got, and at what we need to do next. Right now, we've got three containers, and we've got two node types (category and person) that we want to use for creating categories in those containers. We want all the categories in the topics and moods containers to be of type category, and we want all the categories in the people container to be of type person.

We could start creating those categories right now. But with our current setup, it would be perfectly possible to create categories of type person in the topics container, or vice versa. And while it's OK for that to be permissible when an administrator is creating categories, it's not OK when our users are creating categories. Because - and this is of course completely hypothetical and won't be an issue in real life :-p - our users are dumb and can't be trusted. And besides, even administrators don't want to have options that shouldn't be there. It just makes the interface accident-prone.

Fortunately, the category module allows you to limit categories of a certain node type to only being created within certain containers. This is just the feature we need, so let's make use of it now.

We'll start by configuring categories of type category. Go to administer -> settings -> content types, and click the configure link for the category node type. In the workflow box, you will see a multi-select list labelled category - allowed containers. By default, the only item selected in this list is <All except>, at the top. Leave this item selected, and select the people container as well, by holding down the CTRL key (Command for Mac users), and clicking the people item. This sets the rule that categories of type category can be placed in any container, except for the people container. Hit the save configuration button, and go back to the administer -> settings -> content types page.

Setting allowed containers for categories
Setting the allowed containers for categories of type 'category' to be 'all except people'.

Next, we're going to be configuring the person type to behave in virtually the opposite (i.e. reciprocal) way. Click on the configure link for the person type, and you should see a very similar form being displayed. In the workflow box, you will find a setting called category behavior, with two choices: category, or none. We want this content type to behave as a category, so make sure that category is selected for this option. This setting is not displayed for the built-in category type, because that type has the special behaviour of always being a category (it would be a bit weird if you could set the 'category' type to not be a category!). Also, if you had enabled the containers option, in the allow other content types to be setting (on the administer -> settings -> category page), there would also be a container option here. That site-wide setting affects the options available in this type-specific setting.

For the category - allowed containers select list, just select the people container. This time, the <All except> item must not be selected. This sets it such that categories of type person can only be placed in the people container, and not in any other container. Hit the save configuration button, and you're good to go.

Setting allowed containers for people
Setting categories of the 'person' content type to be restricted to the 'people' container.

That's all the hard setup stuff done. Read on for nothing but fun-filled category and assigned node creation.

Hi, I am just starting to

Hi, I am just starting to try Category module. I want to implement the following structure:

Travel Stories (just a containeri)

  • Story 1 (a CCK custom type)
  • Story 2
  • ....
  • Story n
    • Picture n1 (another CCK custom type)
    • Picture n2
    • ....

One root container (Travel Stories) with many travel stories inside (categories or containers - how to decide?) each having a number of Pictures - that's it.

When I go to Travel Stories container, I want to see a "Add new story" link instead of "Add new categoryi" at the bottom since Travel Story is the only category allowed under Travel Stories.

When a child category (travel story) is created, there are two fields under the "Category information" section: Container and Parent. Why is that so?
Following your setup I was able to get the "right" container set by default. However the Parent defaults to root, which leads to the new category created on the same level as the container. Additionally a menu item is created under Navigation. How to stop that?

What is the best way to implement all this?

Thanks a lot!