Template variables - parent_node_id in adding new content

Author Message

Sao Tavi

Sunday 29 May 2011 10:16:00 am

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.

Niko Goers

Sunday 29 May 2011 11:26:51 am

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.

eZ Publish partner - http://www.all2e.com
http://share.ez.no/directory/companies/all2e-gmbh
http://ez.no/Partners/all2e-GmbH

Lords of Heaven - http://www.LoH-Gilde.de (Created with eZ Publish)
German online gaming guild

About me - http://www.NikoGoers.de

My roadmap, +1 are welcome: http://share.ez.no/community/roadmap/10889

Sao Tavi

Sunday 29 May 2011 12: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?

Sao Tavi

Sunday 29 May 2011 2: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...

Marko Žmak

Sunday 29 May 2011 4:11:28 pm

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.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Sao Tavi

Sunday 29 May 2011 4:45:47 pm

Thank you, Marko, that attribute(show) seems to be really useful. I was wondering how to get a print_r in the template engine :D

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).

Nicolas Pastorino

Tuesday 31 May 2011 12: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 !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:57:21
Script start
Timing: Jan 18 2025 02:57:21
Module start 'layout'
Timing: Jan 18 2025 02:57:21
Module start 'content'
Timing: Jan 18 2025 02:57:22
Module end 'content'
Timing: Jan 18 2025 02:57:22
Script end

Main resources:

Total runtime0.6495 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.1563152.6563
Module start 'layout' 0.00540.0030 740.812539.5156
Module start 'content' 0.00840.6400 780.3281678.3672
Module end 'content' 0.64840.0011 1,458.695320.0938
Script end 0.6495  1,478.7891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4854160.0002
Check MTime0.00130.2041160.0001
Mysql Total
Database connection0.00080.128310.0008
Mysqli_queries0.588190.5480740.0079
Looping result0.00060.0950720.0000
Template Total0.621995.720.3109
Template load0.00180.282820.0009
Template processing0.620095.460620.3100
Template load and register function0.00010.020810.0001
states
state_id_array0.00070.115110.0007
state_identifier_array0.00090.133620.0004
Override
Cache load0.00160.2407430.0000
Sytem overhead
Fetch class attribute can translate value0.00060.093240.0002
Fetch class attribute name0.00100.1580100.0001
XML
Image XML parsing0.00270.414340.0007
class_abstraction
Instantiating content class attribute0.00000.0025100.0000
General
dbfile0.00270.4217300.0001
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs