Forum OpenACS Development: Re: To associate 2 content_types

Collapse
Posted by Antonio Pisano on
Hello Iuri

There is quite some machinery in the content repository to relate stuff to content items, but might be overkill in many cases.

A very generic, no rocket-science way to relate arbitrary acs-objects is the attachments package[1]. It is basically a two columns table referencing acs_objects (with proper on delete cascade defined in case one of the two objects gets deleted).

Hope this helps

[1] https://openacs.org/api-doc/package-view?version_id=5374040&public_p=1&about_package_key=&kind=procs

Collapse
Posted by Iuri Sampaio on
Antonio,

I was expecting to create a relation such as: using acs_rels to create role and type, as in this sample with videos and thumbs :
select acs_rel_type__create_role(
'video_object', --role
'Video', --pretty_name
'Videos' --pretty_plural
);

select acs_rel_type__create_type(
'video_image_thumbnail_rel', --rel_type
'#acs-subsite.Video_Image_Thumbnail#', --pretty_name
'#acs-subsite.Video_Image_Thumbnails#', --pretty_plural
'relationship', --supertype
'video_image_thumbnail', --table_name
'image_id', --id_column
'video_image_thumbnail_rel', --package_name
'content_item', --object_type_one
'video_object', --role_one
1, --min_n_rels_one
1, --max_n_rels_one
'content_item', --object_type_two
null, --role_two
0, --min_n_rels_two
1 --max_n_rels_two
);

Collapse
Posted by Iuri Sampaio on
Hi there,

As one of other solutions, I've written the following chunks to acs_rels data model, plus I’ve added a few other glue codes along with item-add.tcl , photos-add and so on. All them within a new and customized page and package.

Is there any documentation/tutorial about how to use cr_items and revisions within custom packages?

I found none at:
1. https://openacs.org/storage/download/OpenACS_Tutorial.htm?file_id=2938446
2. https://openacs.org/doc/acs-package-dev

Example:
From item_id to album_id
set album_id [relation::get_object_two -object_id_one $item_id -rel_type "ee_item_album_rel"]

and vice-versa
set item_id [relation::get_object_one -object_id_two $album_id -rel_type "ee_item_album_rel"]

Collapse
Posted by Iuri Sampaio on
I guess I got it!
https://openacs.org/doc/acs-content-repository/

I wonder if there's a tutorial as in:
HOW TO USE OBJECTS? :
https://openacs.org/storage/download/OpenACS_Tutorial.htm?file_id=2938446#_Toc229651001

Best wishes,

Collapse
Posted by Iuri Sampaio on
A suggestion:
we could add this thread as a new topic within the documentation
of https://openacs.org/doc/acs-content-repository/

There's an item already, called as: Relating content to other objects.

This thread could be:
Relating content to other content items
https://openacs.org/doc/acs-content-repository/

Best wishes,