How to reference custom fields in a collection template

59 views Asked by At

I am trying to create a custom collection template, which includes some of my custom fields.

This is what I have at the moment: https://gist.github.com/adrigen/06bdc88bda6e9cf20a44

But the error is: NameError: name 'resource_type' is not defined.

I know I need to define that variable, but I cant find the right place to do it. I tried
<metal:block use-macro="context/standard_view/macros/entries" tal:define=" resource_type context/resource_type; >

And a few other places, but it doesn't seem to make a difference. What am I understanding incorrectly?

1

There are 1 answers

0
Adrian Garner On BEST ANSWER

I moved the definition to <div class="icon" tal:define="..."> as per Mathias' suggestion.

Then got the error

Expression: <PathExpr standard:u'context/resource_type'>
Names:

{'container': <PloneSite at /hccrems>,
 'context': <Collection at /hccrems/our-products/our-products/hccrems-purchasable-products/products>,
 'default': <object object at 0xb72c66a8>,
 'here': <Collection at /hccrems/our-products/our-products/hccrems-purchasable-products/products>,
 'loop': {u'item': <Products.PageTemplates.Expressions.PathIterator object at 0xb3dacf6c>},

And noticed that 'context' refers to the collection while item is an object, so I changed it to tal:define=" resource_type item/resource_type;

And now it's good.