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

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 31 2025 01:25:35
Script start
Timing: Jan 31 2025 01:25:35
Module start 'layout'
Timing: Jan 31 2025 01:25:35
Module start 'content'
Timing: Jan 31 2025 01:25:35
Module end 'content'
Timing: Jan 31 2025 01:25:35
Script end

Main resources:

Total runtime0.0239 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.2500151.2266
Module start 'layout' 0.00530.0032 739.4766220.7188
Module start 'content' 0.00860.0137 960.19531,009.9297
Module end 'content' 0.02220.0016 1,970.125041.9922
Script end 0.0238  2,012.1172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002711.2852140.0002
Check MTime0.00114.6453140.0001
Mysql Total
Database connection0.00093.791410.0009
Mysqli_queries0.00218.894130.0007
Looping result0.00000.045910.0000
Template Total0.00114.710.0011
Template load0.00093.686510.0009
Template processing0.00021.004810.0002
Override
Cache load0.00062.472010.0006
General
dbfile0.00031.063780.0000
String conversion0.00000.020040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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