eZ Community » Forums » General » Custom class, attribute_view_gui,...
expandshrink

Custom class, attribute_view_gui, where to put template

Custom class, attribute_view_gui, where to put template

Friday 04 January 2013 2:49:47 pm - 6 replies

Hi,

i have made a custom class in ez publish 4 and want to configure how it is displayed when used in a template via {attribute_view_gui view=viewname attribute=$item.object.data_map.myclass}

.. but i dont find where to put the template, the only one that i found was override/templates/full/myclass.tpl , but this only seems to change the full view, if i use attribute_view_gui with, e.g. view=line and put it to override/templates/line/myclass.tpl nothing happens (as in, it is empty, nothing showing up)

Where do i have to put it? Do i have to modify override.ini?

Friday 04 January 2013 3:40:45 pm

Hi Heiko,

Yes indeed, you have to edit override.ini.append.php and add a new block for the connection between the class and its view, in this case, line view. You'll have some samples in the override.ini default file.

Best regards,

Jean-Luc.

Friday 04 January 2013 4:08:21 pm

Thanx, this is what i have:

   [ref_myclass]
   Source=node/view/full.tpl
   MatchFile=full/myclass.tpl
   Subdir=templates
   Match[class_identifier]=myclass
   [ref_myclass_line]
   Source=node/view/line.tpl
   MatchFile=line/myclass.tpl
   Subdir=templates
   Match[class_identifier]=myclass

And put the templates in override/templates/line and override/templates/full

When calling the url with a browser to a object created from this class, i get the full template, but when using {attribute_view_gui} neigher view=full, nor view=line works, if i do not specify a view, there is some fallback, where i assume it is the first text line of the class definition.

Friday 04 January 2013 4:22:52 pm

Hi,

the override.ini configuration seems to be correct. Did you try to display eZ Debug and check if any template was missing? Did you clear the cache? Do the files have correct permissions to be read?

Friday 04 January 2013 4:34:26 pm

Hi,

{attribute_view_gui} is used to display class attributes and not nodes. For example :

My description : 
{attribute_view_gui attribute=$node.data_map.description}

With your override.ini configuration, you have defined 2 differents templates path for displaying your custom object. If you call /content/view/full/nodeID or /content/view/line/nodeID in your browser, you will see the result of your templates override/templates/full/myclass.tpl and override/templates/line/myclass.tpl .

Now if you want to display your line view in another template (for example in order to have a list of children's), you have to use {node_view_gui} and not {attribute_view_gui} :

Here is one of my children custom class objects :
{node_view_gui content_node=$childrenNode view=line}

Hope it helps,

Paul

Monday 07 January 2013 4:39:09 pm

Thanx, unfortunately it still does not work.

I now use node_view_gui, because a list of children is exactly what i want. To go more into detail: I have a 'product' and that has a 'manufacturer' both are custom classes and the manufacturer is connected via object relation when editing a product.

So in the template that displays a product i now have:

    {node_view_gui content_node=$manufacturer view=line}

When i now enable template debugging, at the place where the manufacturer address should show up, the template debug says:

    extension/ezwebin/design/ezwebin/templates/node/view/line.tpl

And in the list of used templates it says:

    node/view/line.tpl   <No override>   extension/ezwebin/design/ezwebin/templates/node/view/line.tpl

But shouldn't this override it:

    [prod_addr_line]
    Source=node/view/line.tpl
    MatchFile=line/myaddress.tpl
    Subdir=templates
    Match[class_identifier]=myaddress

Wednesday 09 January 2013 4:30:41 pm

Ok, i just found one weired thing:

If i remove the 'Match' line, it works, but i assume i then overwrite just everything that is shown as line?

myaddress is exactly that is shown as class identifier in the admin menu, how can this be?

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from