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