Forums / Developer / $node.data_map.(...) versus $node.object.data_map.(...) ?

$node.data_map.(...) versus $node.object.data_map.(...) ?

Author Message

Craig Hirsch

Thursday 07 April 2005 9:44:07 am

Can someone clarify for me:

1) The conceptual difference between accessing a particular content item's data map via $node.data_map.(...) and accessing it via $node.object.data_map.(...) ?

2) The practical effects of doing things one way or the other...?

Thanks in advance.

--
chirsch{AT}gmail{d.t}com

Paul Forsyth

Thursday 07 April 2005 10:31:33 am

They both call the same php function so both return the same result.

In some circumstances you may not have access to the node and use $object.data_map instead.

paul

Kristian Hole

Friday 08 April 2005 12:11:16 am

1)
The conceptual difference is that the node does not have a data_map. The node "contains" the object, so $node.object.data_map is the correct way. $node.data_map is a shortcut.

2)
Should be no practical difference.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Hans Melis

Friday 08 April 2005 12:43:50 am

2) There is a practical difference depending on some conditions.

- You must be using ezpublish 3.5
- TemplateOptimization must be enabled
- The variable $node must not be set by a module, but fetched in a template (in other words, a template loaded by a custom module).

In those conditions, $node.object.data_map doesn't work, but $node.data_map does.

http://ez.no/community/bugs/templateoptimization_causes_problems

Hans
http://blog.hansmelis.be

Kristian Hole

Friday 08 April 2005 12:54:18 am

I was ofcourse just thinking of using $node in the view templates in my little head. Must still early in the morning ;)

Thanks for your comment Hans!

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Xavier Dutoit

Friday 08 April 2005 12:58:09 am

Good question, rising an interresting point: too many ways of doing the same thing doesn't add any value but obfuscate.

What's the added value of $node.data_map instead of $node.object.data_map ? to save 7 bytes ?

Please choose an officially recommanded way, document it properly and declare obsolete the others.

Orthogonality is the best documentation ;)

http://www.sydesy.com

Craig Hirsch

Friday 08 April 2005 9:31:52 am

I will also add this to the discussion - right now, using $node.object is very dangerous when referencing images, because of the PHP bug noted here (whose cause I still don't really comprehend):

http://www.ez.no/community/bugs/call_to_undefined_function_storedata

Working around this bug prompted my question originally -- after two solid long days of working I have finally eliminated all reference to $node.object.data_map.(image datatype attribute)[original] in my code, replacing it with $node.data_map.(...).

So.. it would seem that for all template development the safest bet by far is to use $node.data_map rather than $node.object.data_map, given the bug and Hans' TemplateOptimization comments.

Does everyone agree?

--
chirsch{AT}gmail{d.t}com

Xavier Dutoit

Friday 08 April 2005 9:48:14 am

I don't know what works best in every specific case, but on a conceptual level, I think that datamap belongs to the object, not to the node.

node.data_map just fuels the confusion between object and node IMO.

Xavier

http://www.sydesy.com

Kristian Hole

Monday 11 April 2005 4:16:28 am

I agree with you Xavier that using $node.object.data_map is conceptually better and clearer (and less confusing).

I think the reason that this was implemented was to reduce the overhead for getting the data_map. (Less calls to functional attributes.)

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

eZ debug

Timing: Jan 15 2025 07:47:32
Script start
Timing: Jan 15 2025 07:47:32
Module start 'content'
Timing: Jan 15 2025 07:47:33
Module end 'content'
Timing: Jan 15 2025 07:47:34
Script end

Main resources:

Total runtime1.4858 sec
Peak memory usage6,144.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0075 684.4063214.7734
Module start 'content' 0.00751.3535 899.17972,008.8906
Module end 'content' 1.36100.1248 2,908.0703643.4688
Script end 1.4857  3,551.5391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00740.4977210.0004
Check MTime0.00150.1019210.0001
Mysql Total
Database connection0.00140.092810.0014
Mysqli_queries1.362391.68882110.0065
Looping result0.00220.14712080.0000
Template Total1.452697.820.7263
Template load0.00510.342520.0025
Template processing1.447597.423920.7238
Template load and register function0.00150.101410.0015
states
state_id_array0.00150.103510.0015
state_identifier_array0.00230.152120.0011
Override
Cache load0.00480.3232520.0001
Sytem overhead
Fetch class attribute can translate value0.00160.106960.0003
Fetch class attribute name0.00300.2009130.0002
XML
Image XML parsing0.00280.189860.0005
class_abstraction
Instantiating content class attribute0.00000.0024170.0000
General
dbfile0.00140.0935380.0000
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/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/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs