Forums / Setup & design / detect object ID in custom tag template

detect object ID in custom tag template

Author Message

Marko Žmak

Tuesday 10 March 2009 5:24:53 am

I would like to do this:

- insert a custom tag in a XML field of an Article
- in the template of that custom tag find out what is the object id of the Article where the tag was inserted.

Is this possible and how?

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

Hubert Farnsworth

Jean-Yves Zinsou

Tuesday 10 March 2009 5:33:41 am

Hi there,
i would first try
{attribute(show,$object)}
and see what it returns...

And then figure out where to go...

What do you think ?

....

Jey

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Marko Žmak

Tuesday 10 March 2009 5:52:15 am

Unfortunately using the $object variable doesn't work, I've already tried it. Any other idea anyone? Is this possible to do?

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

Hubert Farnsworth

Igor Vrdoljak

Tuesday 10 March 2009 6:53:56 am

In my experience, it is not possible to get this information (objectid, nodeid) in custom tag. At least not in 3.9 version of eZ Publish.

It seems that the only variables visible are those passed by custom tag parameters.

http://www.netgen.hr/eng
http://twitter.com/ivrdoljak

Igor Vrdoljak

Wednesday 18 March 2009 4:02:55 am

I seems that it is possible to get current node (and objectid from it) in custom tag after all :), by using global variable $#node. I found it being used in 4.1 custom tag (children_menu):

<div class="class-{$#node.class_identifier}">

Is there a complete list of variables available in custom tags?

http://www.netgen.hr/eng
http://twitter.com/ivrdoljak

Marko Žmak

Wednesday 18 March 2009 4:16:03 am

I hope it works in eZ 3.10.1 too, I'll give it a try.

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

Hubert Farnsworth

Igor Vrdoljak

Wednesday 18 March 2009 10:05:32 pm

I think it should work. I tested it on a 3.9 installation and it worked.

It would be nice if it was documented, though. On a previous project we lost quite a bit time on this. :)

http://www.netgen.hr/eng
http://twitter.com/ivrdoljak

André R.

Thursday 19 March 2009 12:07:36 am

All variables in 'parent' templates are available by using global scope on variable ('#')*.
As for witch variables available inline in custom template, it should be its attributes ($name and $align as of 4.1), $content and any custom attributes you may have on the current custom tag.

* note that variables in node/system templates are not available in pagelayout and its templates, see operator ezpagedata_[set|append] for this (uses persistent_variable node templates and private class member for system templates internally) .

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

eZ debug

Timing: Jan 19 2025 01:16:55
Script start
Timing: Jan 19 2025 01:16:55
Module start 'content'
Timing: Jan 19 2025 01:16:55
Module end 'content'
Timing: Jan 19 2025 01:16:55
Script end

Main resources:

Total runtime0.1464 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.0703180.8281
Module start 'content' 0.00630.0056 769.8984106.0234
Module end 'content' 0.01190.1344 875.9219534.0781
Script end 0.1464  1,410.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.3962200.0002
Check MTime0.00151.0041200.0001
Mysql Total
Database connection0.00090.610610.0009
Mysqli_queries0.103670.72761410.0007
Looping result0.00110.78371390.0000
Template Total0.134191.610.1341
Template load0.00090.592810.0009
Template processing0.133290.965110.1332
Override
Cache load0.00060.420710.0006
Sytem overhead
Fetch class attribute can translate value0.00080.541710.0008
XML
Image XML parsing0.00030.218510.0003
General
dbfile0.00291.9906200.0001
String conversion0.00000.004130.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs