ez.no / exponential / documentation / customization / components / datatypes / ezobjectrelation / selecting related objects with dropdown boxes, checkboxes, etc.
These documentation pages are no longer maintained. Please visit the new documentation site.
Normally Exponential uses a browse function to select objects which should be linked. This workflow might be sufficient for occasionally linking objects but it is very time consuming. It is much easier to choose from a dropdown list of available objects. You also have the option to restrict which objects are allowed to be linked. This all can be achieved just with template programming.
To achieve this, you should do the following steps:
1. Create the directory templates/content/datatype/edit in your current design directory.
2. Create the file ezobjectrelation.tpl in this directory with the following content:
{section name=top loop=fetch( content, list, hash( parent_node_id, 2 ) )} <select name="ContentObjectAttribute_data_object_relation_id_{$attribute.id}"> <option value="{$:item.contentobject_id}">{$:item.name|wash}</option> </select> {/section}
Now, if you create a document which has an object relation attribute then you should get a dropdown box of all objects in the root directory. This is just a first example and it should be refined.
The important thing to remember is that the HTTP POST variable ContentObjectAttribute_data_object_relation_id_{$attribute.id} has the content object id (not the node id!) as value of the object you want to link to.
Comments