Skip to content
CPyle edited this page Mar 7, 2012 · 5 revisions

Usage

This is a field that allows you to select another Content Item using a drop down box. The selectable Content Items that appear in this list are controlled via a Projector Query.

For example, if you have Beer and Brewery content types, you can create a Query that selects all Breweries, add a "Brewery" field to the Beer content type, and use the "Breweries" Query to populate the drop down list.

Why is this better than Lists?

  • The Lists interface is somewhat cumbersome to use.
    
  • You can reference anything without the requirement of it being a "Container."
    
  • You can have the same item be related to multiple different Content Items in different ways, whereas Lists limits you to a single relationship.
    

Projections and Tokens

This is where the power of this module really comes into play, as you can now display information about referred content items inside your query results.

Using the token format {Content.Fields.PartName.ContentReferenceFieldName.ContentItem} gives you access to all of the data in the referred Content Item. In our Beer example, this would be {Content.Fields.Beer.Brewery.ContentItem}. In conjunction with the Projector feature that allows you to rewrite your results using Tokens, this essentially allows you to arbitrarily join other Content Items onto your result.

We can do more than this though.

The Context Token

Enabling the Context Token feature (Under the Content category) allows access to the currently displayed item. This is intended to be used by Queries. It will be available (and is especially useful) if your Query is being displayed inside a widget on the page.

It is accessed via the token {Context.This}

Example:

Create a Query with a filter for the Beer content type. Add a second filter to this on the "Brewery" ContentId property, with the value being equal to {Context.This.Id}. This will filter the list to only Content Items that reference the current Brewery. Use this query in a Widget that appears on Brewery pages to complete the example.

Clone this wiki locally