Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did it with a behavior, by adapting to INameFromTitle</p> <p>in <strong>behaviors.py</strong></p> <pre><code>class INameFromBrandAndModel(Interface): """ Interface to adapt to INameFromTitle """ class NameFromBrandAndModel(object): """ Adapter to INameFromTitle """ implements(INameFromTitle) adapts(INameFromBrandAndModel) def __init__(self, context): pass def __new__(cls, context): brand = context.brand model = context.modeltype title = u'%s %s' % (brand,model) inst = super(NameFromBrandAndModel, cls).__new__(cls) inst.title = title context.setTitle(title) return inst </code></pre> <p>in <strong>behaviors.zcml</strong> or <strong>configure.zcml</strong></p> <pre><code>&lt;plone:behavior title="Name from brand and model" description="generates a name from brand and model attributes" for="plone.dexterity.interfaces.IDexterityContent" provides=".behavios.INameFromBrandAndModel" /&gt; &lt;adapter factory=".behaviors.NameFromBrandAndModel" /&gt; </code></pre> <p>Then disable INameFromTitle behavior in <code>profiles/types/your.contenttype.xml</code>.</p> <p> </p> <p>Voila. This integrates very well and shows a proper title in the default view and navigation. Removing <code>context.setTitle(title)</code> from the adapter would just leave us with a proper id, but no title set.</p> <p>This does not change the title autocratically after editing. I had, so far, no success with overriding the <code>klass</code> property of my content types, as often suggested.</p> <p>If you define the <code>title</code> attribute in your schema, like:</p> <pre><code>class IBike(form.Schema): """A bike """ title = schema.TextLine( title = _(u'Title'), required = False, ) </code></pre> <p>you can easily change the title later. Hiding the title field in the addForm should be done, to avoid misunderstandings.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload