The form is coming out fine but I am having issues displaying the variables that come from the behavior elements. For my other custom dexterity field, such as policy_program, I could display the value by doing: <span tal:content="context/policy_program" />
I am having issues displaying the behavior elements e.g. the event URL, etc. Any advise would be most appreciated. Thank you.
Andreas, thank you so much. Please excuse my ignorance but where do I put that import statement? In the interface.py file, model .xml file or in the template .pt file? Please advise. Thank you.
## -*- coding: utf-8 -*-
from Products.Five import BrowserView
#and everything else you need to import
class NcssView(BrowserView):
# @property
def something(self)
return 'some thing'
Then, you can do this in you 'template.pt'
<span>${view/something}</span>
For the events there are some 'special stuff', so maybe you can subclass the event view ? You need to google it / read the docs ( or ask someone that knows this better than me )
Browser views are a fundamental concept of Plone and wonder why we need to teach this to someone or look up the docs for you with your year long experience with Plone.
Thanks so much for the link. Yeah, that behavioral elements for events is throwing me for a loop. I am going to check out your suggestion and see where it leads me. If worse come to the worse, I am going to just create my own custom event content type and try not to mess with the "special stuff" that comes with the event content type. Thanks so much.
Well, Andreas. First of all, I don't program browser views often. So even if I have used Plone for quite some time, that is no indication that I understand all the ins-and-outs of browser views. I have used browser views many times in the past. However, not so in having to pull up fields that don't even appear in my model xml files. Because of that it did not even occur to me that it relates to browser views. I thought it dealt with something else. Second of all, I am not going to say I know something when I don't, and I am not shy to say that I don't understand something when I don't. It is better to be honest than to play bluff. So there it is. Espen gave me that link yesterday and I am looking through it now. Thank you for sending that same link to me today as well. It is very much appreciated.
I think we could all do with a reminder that not everyone in this forum is a hardcore Python developer. One of the great strengths (in my opinion) of Plone is that it can be customized by non-developers. Every one of us has strengths and areas in which we need help, so please be kind to each other.
I remember my own confusion at how one accesses values of fields that are defined by behaviours. Let me see if I can dig up some examples.
from collective.gtags.behaviors import ITags
doc = Document('doc')
tags_adapter = ITags(doc, None)
# now you can get values of fields defined by the ITags behaviour:
my_tags = tags_adapter.tags
Someone please correct me on this: I don't think this is doable in TAL, so you have to create a browser view that will contain this code in a method, and then in the browser view's template you can call that method. Continuing the above example, if what you wanted was those tags you could define a method called my_tags that returns those tags, and then your TAL expression could call it with something like this: