Rendering new text field?

guys,
i am learning Plone 5, 6 but currently i must create a new content type in plone 4.3 :slight_smile: based on an old content type:

UrgencySchema = Actuality.schema.copy() + atapi.Schema((

atapi.StringField('urgency_link',
    write_permission = ModifyPortalContent,
    storage = atapi.AnnotationStorage(),
    required = True,
    widget = atapi.StringWidget(
        label = _(u'Urgency link')
    )
),

))
new content type:
class Urgency(Actuality):
implements(IActuality, IUrgency)

meta_type = "Urgency"
schema = UrgencySchema

title = atapi.ATFieldProperty('title')
description = atapi.ATFieldProperty('description')

def getUrgency_link(self):
    values = self.objectValues()
    return [x for x in values if IUrgency.providedBy(x)]

atapi.registerType(Urgency, PROJECTNAME)

in plone site i can create new Urgency :slight_smile: but it displays without 'urgency_link' field. When i edit it i see 'urgency_link' :slight_smile:

Please give hint how to render this new content type?
Tank thank for your time :slight_smile:

Then use Dexterity for content types but not Archetypes (deprecated, no longer supported with Python 3).

In Plone >= 5 you can basically just make your content type in the Dexterity Control panel and then export / copy the code to your content type (until you know all the syntax).

After that, I would make a browser view for your content type.

The lazy way to do this is to use plonecli: GitHub - plone/plonecli: Plone Command Line Client - for creating and working with custom add-ons and themes

You would basically do

  1. Create an add-on GitHub - plone/plonecli: Plone Command Line Client - for creating and working with custom add-ons and themes
  2. Add a content type ( GitHub - plone/plonecli: Plone Command Line Client - for creating and working with custom add-ons and themes)
  3. Add a view
  4. Add your product to the eggs section of buildout.cfg
  5. Add /src/my product to the develop section of buildout (and run bin/buildout.cfg)
  6. you need to enable the view for the content type, but if you struggle it can be set in the ZMI in /portal_types

Your browser view would be something like:

    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      i18n:domain="medialog.fender"
      metal:use-macro="context/main_template/macros/master">
<body>
  <metal:block fill-slot="content-core">
 
    <p>${context/urgency_link}</p>
   </metal:block>
</body>
</html>

@zopyx we will have Plone 5 after about half year :smiley: enough time to learn Plone 5.
@espenmn Thank you very much for your long advice! i will study your text :slight_smile: appreciated!

for Plone 4.3 i editted
.../our_custom_theme/newsitem_view.pt
adding somewhere the code:

and it worked like charm :slight_smile:

Glad it worked.

One note about Plone 5:
In the templates you usually do not need 'complicated tal' anymore, so you can write (if you want to):

<p tal:condition="content/getUrgeny_link">
    <span>${context/urgencly_link_label}</span>
   <a href="${context/getUrgency_link}" target=_blank>${context/getUrgency_link}</a>
</p>

( I recommend using 'context' instead of 'here' )

Plone Foundation Code of Conduct