Forum OpenACS Development: Re: Associating photos with blog entries (or generically stuff with stuff)

The code in /contrib/packages/simulation/citybuild/object-edit uses cr rels to embed images in marked up text. In this case, the text is the content of a "sim_prop" or "sim_location" or "sim_character". An object can have up to 10 images associated with it (this arbitrary limit is set in the data model, like this:
select content_type__create_type(
    'sim_location',                -- content_type
    'content_revision',            -- supertype
    'Location',                    -- pretty_name,
    'Locations',                   -- pretty_plural
    'sim_locations',               -- table_name
    'location_id',                 -- id_column
    null                           -- name_method
);

select content_type__register_relation_type (
    'sim_location',                -- content_type
    'image',                       -- target_type
    'image',                       -- relation_tag
    0,                             -- min_n
    10                             -- max_n
);

When you select an image from the dropdown (which shows all cr_items with type 'image'; type is set when it is uploaded, in this case using the same object-edit form but with image instead of location selected), you get an xml snippet that can be pasted into the body context of the sim_location. Whenever the sim_location is rendered, this xml snippet is converted to <img src="etc etc etc">.

You can install simulation on a HEAD server, go to citybuild, and try it yourself, or ping me for a login on a stable test server.

If this is going in the right direction for you, let me know and I can explain in more detail.

It's on my long list of things I want to do ...

The nicest solution would be to:

1) migrate blogger to use CR

2) use cr_item_rels and the <relation> tag as mentioned by Dave and Joel.

Any volunteers for this?

I'm contemplating thinking about moving pinds.com to a 5.1 platform, and this is one of the features I really want in my new site. And being able to actually use it on a daily basis is a strong motivator for adding features. However, the process of moving data to the new platform is going to be fairly painful ... :(

/Lars