You are here: Home / What do you need? / Help and documentation / Plone Info / Reference fields and widgets

Reference fields and widgets

by Darrell Kingsley last modified Mar 13, 2014 12:55 PM
With particular regard to ReferenceBrowserWidget, as that's the one we must often use

Special fields for setting up a ReferenceBrowserWidget

There are a few fields you need in your field definition, and therefore in the tagger values for the field in your UML. They are:

  • widget:type = ReferenceBrowserWidget
  • widget:startup_directory = /news/somefolder (doesn't need plone site id)
  • widget:restrict_browsing_to_startup_directory = True|False
  • relationship = "KnowsAbout" - this is an arbitrary value which defines the references in the reference catalogue. Two difference reference fields in the same content typeMUST have different values or both will display the same set of references (those from the second field)
  • multiValued = True|False

REMEMBER - you must also add an imports statement to your class definition:

imports = from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget

For some more relationships info see:

References are to objects not to brains objects

As far as I can recall from a conversation with someone in the Plone chat room ages ago,reference fields hold references to the objects themselves and NOT some kind of brains object in the portal catalog.

This means that getting the objects is a different thing than we're used to. For example, getting the URL of the referenced object(s) seems round the houses. In the end (in spiderweb page) I did it for internal links on images, by converting the image box brains into a proper object, using the accessor method to get the reference, and then absolute_url() on the object returned. This did NOT work on the reference to the object when the results of the reference field are stored in the portal catalog i.e. a brains representation of thereference field. In this case absolute_url() returns an URL like

To sum up:

link = box.getInternalLink
return link.absolute_url()

DOES NOT WORK (where box is the brains and getInternalLink is stored in the portal_catalog)


obj = box.getObject()
link = obj.getInternalLink()
return link.absolute_url()


Therefore it looks as though it is pointless storing reference fields in the catalog.

Reference catalog

That's because there's a special catalog for references which you can use to get references and back references. See this link: