Personal tools
You are here: Home Documentation How-tos Tagging your content using custom content types
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Tagging your content using custom content types

This How-to applies to: Any version.
This How-to is intended for: Integrators, Customizers

Tagging is a nice way of connecting content within your Plone site (and outside of your Plone site too). Here's how to add this functionality to your own content-types.

Plone has a built-in mechanism for tagging content-types called Keywords. When editing standard Plone content, you’ll find Keywords on the “properties” tab.

You can also add this field to your own new Archetype content-types by adding a “subject” field like this:

LinesField(
name='subject',
widget=KeywordWidget(
label="Keywords",
label_msgid='myconent_label_subject',
i18n_domain=' myconent ',
),
accessor="Subject",
searchable=True,
multiValued=1
),
Or if you’re generating your content via ArchGenXML (see ArchGenXML Introduction), add a field called “subject” of the “lines” type, and make sure you use these tagged values (screenshot of tagged values for “subject” field in ArgoUML):

Keyword UML Tagged Values

Moving the Keyword field for existing content types

For some content-types, Keywords should be front-and-center and not out-of-sight in the Properties tab. If you're creating your own content-type, you just need to add the field as explained above and you're done.

If you'd like to modify an existing content-type (e.g. create a ConferenceNewsItem based on NewsItem):

  1. Using ArgoUML, you can "subclass" the default content-types. See How to subclass an ATContentType in 7 Minutes
  2. In the generated Archetype code, you'll see the "###code-section after-schema". Just modify the schema by adding code in that section (so that regenerating the type won't overwrite). Also see Swapping fields around in an ATContentTypes subclass
##code-section after-schema #fill in your manual code here

# move subject field to main form (default schemata), and put it after the existing 'text' field
ConferenceNewsItem_schema['subject'].schemata='default'
ConferenceNewsItem_schema.moveField('subject', after='text')

##/code-section after-schema

Further Thoughts - Connecting with External Web 2.0 Services

Now that you've tagged your Plone content, you can use those same tags to pull in data from external Web 2.0 services - such as blogs from Technorati, products from eBay, images from Flickr, etc. For an example, see Mashups in Plone: Leveraging Web 2.0

Related


other search terms: mashup, mashups, tag, tags, ploneconf2006


by Brian Gershon last modified October 29, 2006 - 17:21 All content is copyright Plone Foundation and the individual contributors.

Customized NewsItem with Keywords

Posted by Holden Hao at April 2, 2007 - 02:06
Hi. How is the same done with customized content types without using ArchGenXML or ArgoUML? Like if I just want the keywords to display in the edit page of a customized version of NewsItem.

Customized NewsItem with Keywords

Posted by Brian Gershon at April 2, 2007 - 04:07
Hi Holden, the process is the same for your custom ConferenceNewsItem (subclassed from NewsItem) as if you created it via ArchGenXML. You just need to add the two lines (shown above after "##code-section after-schema line") after you define your custom schema. This will ensure the Subject field, which was defined in by NewsItem's schema, is moved within the complete schema so that Keywords appears on the main edit form, and placed after the edit field. The only difference between your home-grown one and the ArchGenXML one, is that ArchGenXML adds comments for where you need to add these lines.

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by