Share » Forums » Developer » select field for object relation

select field for object relation

select field for object relation

Monday 04 August 2003 12:35:48 am - 4 replies

Author Message

Bruce Morrison

Tuesday 05 August 2003 7:08:39 pm

Hi Kai

I've also come across this issue and looked into it in some depth.
http://ez.no/developer/ez_publish_3/forum/developer/related_objects_choosing_from_a_dropdown_instead_of_using_browse

Unfortunately it does not seem possible to achieve this with templates alone. After the related object is select from the browse window entries are made in the database to link to related object. Because of this functionality it is not possible to do this in the object edit screen.

I have been considering how to handle this. I think there are a couple of options.

1. Create a new data type "Relational Object - Select". This would allow you to nominate a node (and possibly a class id) from which the dropdown is populated. When the object is published the correct entries are created in the database.

2. Use the keywords feature to link items. Haven't looked at these yet but it may be a solution without having to code a new extension.

Cheers
Bruce
designIT

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Kai Duebbert

Friday 22 August 2003 3:02:27 am

Ok, found the solution. It's really simple after all and I wonder, why I didn't get it to work before. (Tried it on 3.2b1 but it also should work on 3.1)

All you have to do is change the "edit" template for the Object Relation datatype:

1. copy design/standard/templates/content/datatype/edit/ezobjectrelation.tpl to your custom design folder. Or start with an empty one.
2. The crucial line for assigning an object relation is:
<input type="hidden" name="ContentObjectAttribute_data_object_relation_id_{$attribute.data_int}" value="[CONTENTOBJECT_ID]" />

Change the "[CONTENTOBJECT_ID]" to the id of an object you want to link. E.g. I use a dropdown select box and it works like a charm.

I found it difficult to understand how the object relation actually works at first. As soon as you create a new object with object relation fields, it creates new database entries for them (have a look at contentobject_attributes and compare to the source code of the generated webpages). This is why it was hard to understand (for me).

If there is demand, then I will write a small howto in the documentation area.

Have fun,
Kai

ruud prein

Thursday 29 January 2004 2:52:45 pm

If you can find some time to write a doc about this I would be very gratefull.

regards,

Ruud

---
groet,

Ruud

Trond Åge Kvalø

Monday 23 February 2004 7:09:19 am

Hello Kai!

We're building an LMS based on eZpublish and would very much like to create relations between users and courses. In our implementation an admin user can create users and courses. Then we would like the admin user to create a "course license" with the userid and the courseid. From the little I've seen about object relations so far, I beleive that is the best option here.

Could you please provide us with an example on how to accomplish this?

Best regards
Trond Kvalo
Atlantia as
http://www.atlantia.no/

trondåge

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu