This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Template variables - parent_node_id...
expandshrink

Template variables - parent_node_id in adding new content

Template variables - parent_node_id in adding new content

Sunday 29 May 2011 7:16:00 pm - 6 replies

When adding a new element in front end (so not from admin control panel) I need to access the id of that element's parent (I created a new datatype that needs to care about this info).

It should be something like $module_result.parent_node_id. The bad part is that $module_result seems not to be set, neither $pagedata or other things I tried.

Modified on Sunday 29 May 2011 8:12:36 pm by Sao Tavi

Sunday 29 May 2011 8:26:51 pm

Hi Sao,

try this:

 $object.current.main_parent_node_id

It should work.

The most interesting variables in /content/edit are $object and $content_attributes I would say.

Sunday 29 May 2011 9:13:40 pm

Thank you for your reply, Niko

Unfortunately, that did not work. Also

     {foreach $object as $item}
        {$item} az
        {/foreach}

Returned nothing, not even the az that would say that it went through the loop. On the other hand, not even the $pagedesign variable is not set, and it is used for sure in the display of the page.

So... my conclusion is that almost no variables are set before creating the form, and that is in the core of eZ, so I cannot change the location where to create it.

On the other hand, I just found where I can set template variables in php. Is there any global that knows the page id or the parent id?

Or is it possible to be a scope change, so that I cannot access the variables set before?

Modified on Sunday 29 May 2011 10:02:18 pm by Sao Tavi

Sunday 29 May 2011 11:00:49 pm

Oh, well, it seems there is a magical attribute_edit_gui that is blocking all the variables except the mentioned ones. One more step, it seems...

Monday 30 May 2011 1:11:28 am

Hi Sao, just a few suggetions:

  • try using $object.current.temp_main_node
  • try using {$object|attribute(show)} and look at the output you get
  • you can pass parameters to attribute_edit_gui the same way you pass it to {include}, for example like this: {attribute_edit_gui attribute=myattribute some_parameter='some_value'}. After that, you can use this parameter in the attribute edit gui template like this: $#ContentAttribute:some_parameter
  • you can use this parameters/variables also in the templates that are included from the attribute edit gui template, like for example the embed template for an object inside an XML Block attribute

Hope some of this helps.

Monday 30 May 2011 1:45:47 am

Thank you, Marko, that attribute(show) seems to be really useful. I was wondering how to get a print_r in the template engine big-smile.gif Emoticon

I managed to finish the editing part of this datatype. This datatype should create a common relation between 2 objects, one of them being the parent of the object that contains this datatype. Also, one object cannot have 2 children that connect to the same other object, nor have a child that connects to him. This is the part that I managed to do so far.

The problem now is that also the other object should know of this relation (so not only the object that has the child with this datatype). One way to achieve this is by automatically creating a child at the other object that will have a relation with the first object.

Is there any other way to do this? Is it possible to get the list of objects that connect to a specific object? I am using the same connection type as object relation datatype (I actually got the code from there, I just edited it a little bit to suit my needs).

Modified on Monday 30 May 2011 12:54:03 pm by Sao Tavi

Tuesday 31 May 2011 9:30:04 am

Hi Sao, Marko, Niko,

An interesting blog-post + discussion by Steven, you should have a look at this : http://share.ez.no/blogs/steven-e.-bailey/wherefore-art-thou-data (discussion here)

Cheers !

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from