Forums / Setup & design / Retrieving parent when creating a new object
Thomas Nunninger
Tuesday 17 January 2006 7:58:17 am
Depending on the parent where a new object is created I want to prefill an (object relation) attribute. But in the templates/content/datatype/edit/ezobjectrelation.tpl I do not have access to the parent because the object doesn't contain this data (yet). When editing an earlier created object that information is given.
Is there any possibility to retrieve the parent object/node? Where is the parent node/object saved while creating a new object? Or do you have any other ideas?
Thank you
Thomas
Esteban Rodriguez
Tuesday 17 January 2006 10:39:28 am
Hi Thomas,
Let me see if I got you right. I sometimes use the parent object when creating a new object to get some attribute or other. Say you have a folder in which you have the users post images, something like a guest book.I generally use the description of the parent folder for the posting instructions in this guestbook affair, this description is brought by the edit template.
{let Parent=fetch( 'content', 'node', hash( 'node_id', $object.current.main_parent_node_id ) )} {$Parent.object.data_map._NEEDED_ATTRIBUTE_} {/let}
I guess you could use that to fetch whatever attribute you need from the parent for your object relation.
Hope it helps
I have great faith in fools; self-confidence my friends call it. http://presencia.net
Tuesday 17 January 2006 1:30:07 pm
Hi Esteban,
thank you for your reply. My problem was a little bit different (but just a little bit :-) I needed the parent object in an attribute_edit_gui template. I didn't find a way to access the parent directly from this template. So I originally tried to pass the variables in edit_attributes.tpl - but I had a typo :( Now it works.