Forums / Developer / Overriding View Templates For Datatypes

Overriding View Templates For Datatypes

Author Message

Tristan Koen

Friday 23 May 2003 1:20:58 am

I have a custom template for an article object that contains an embedded object. When displaying the embedded object using
{attribute_view_gui attribute=$node.object.data_map.related_object}
all I get is the name of the related object.
Ideally, I would like to display a number of the attributes of the related object here.

Looking through the forums and howto documents, it appears that some people have had some success by placing an embed_class_XX.tpl file in the design/mySchema/override/templates/content/view directory, but only with an embedded object id in an XML attribute.

Looking at the debug output, the default related object output is determined by /design/standard/templates/content/datatype/view/ezobjectrelation.tpl.

Anyone have any idea how to override this template for a specific class?

Selmah Maxim

Friday 23 May 2003 3:43:13 am

Hi ..

u can copy /design/standard/templates/content/datatype/view/ezobjectrelation.tpl

to
/design/MYDISIGN/templates/content/datatype/view/ezobjectrelation.tpl

Let`s say u wanna get foreach class another look from Ezobectrelation, the pass vars to ezobectrelation.tpl :

{attribute_view_gui attribute=$node.object.data_map.related_object Classid=7}

then is ezobectrelation.tpl :

{switch match=$Classid}
{case match=7}{*class # 7}
LALALA
{/case}
{case match=8}{*class # 8}
LALALA
{/case}
.
..
{/switch}

thats it !

Tristan Koen

Friday 23 May 2003 6:50:50 am

Hi Selmah,

Thanks for the idea. It would definitely work, but it is a bit of a hack. Surely there must be a mechanism within the ezPublish framework that would do the trick?
If there is no such mechanism, then I have to question why bother with related objects? It is far cleaner and more maintainable to place an object reference into an XML text attribute (in my opinion anyway).