Forum OpenACS Development: CR child items - 'not allowed in this container'

I have created a custom content type, 'cu_sequence', whitch has been registered with the root folder (-100) while I'm testing...:
select content_folder__register_content_type(
        -100,                   -- folder_id
	'cu_sequence',          -- content_type
        'f'                     -- include_subtypes
);
It is possible to create an item by calling my content type's "new" function with NULL as parent_id:
dotlrn-test=# select cu_sequence__new (
3238 ,          -- sequence_id
null ,          -- parent_id
'Tree Test20' , -- name
null ,          -- title
null ,          -- description
'text/plain' ,  -- mime_type
2721 ,          -- owner_id
3093 ,          -- package_id
'cu_sequence' , -- content_type
2721 ,          -- creation_user
'127.0.0.1' ,   -- creation_ip
null ,          -- context_id
'f' ,           -- is_live
'text'          -- storage_type
);
dotlrn-test# 
 cu_sequence__new 
------------------
             3238
(1 row)
However, when I grab a new object_id and use it as the item_id while using the existing item_id (3238) as parent_id to the new item, in order to create a child item, I get the following error:
dotlrn-test=# select cu_sequence__new (
3244,          -- sequence_id
3238 ,          -- parent_id
'Tree Test21' , -- name
null ,          -- title
null ,          -- description
'text/plain' ,  -- mime_type
2721 ,          -- owner_id
3093 ,          -- package_id
'cu_sequence' , -- content_type
2721 ,          -- creation_user
'127.0.0.1' ,   -- creation_ip
null ,          -- context_id
'f' ,           -- is_live
'text'          -- storage_type
);
dotlrn-test=#
ERROR:  -20000: This items content type cu_sequence is not allowed in this container 3238
How do I permit an item to "contain" another item of the same (or different) content type? Thanks,
Collapse
Posted by Dave Bauer on
Ola, check out this doc:

https://openacs.org/doc/acs-content-repository/guide/object-relationships.html

Here is a relevant part:

"An API procedure, content_type.register_child_type, may be used to specify the minimum and maximum number of children of a particular content type that an item may have. "

Collapse
Posted by Ola Hansson on
Thank you Dave!

I added the following and it works.

select content_type__register_child_type(
        'cu_sequence',          -- parent_type
	'cu_sequence',	        -- child_type
	'generic',              -- relation_tag
	0,                      -- min_n
	NULL                    -- max_n		
);