Working With Related Assets

Contents

When you create a custom item type, you can define a field as being a Related Asset. Typical uses of this capability include:

  • Associate a number of images with a project
  • Associate a logo image with a company
  • Associate a PDF document with an item

Defining a Related Assets Field

When creating a custom item type, add a field and set the field type to Related Asset.

If you want the pop-up list for this field to show all assets, leave the Type Options field blank. To limit the pop-up to assets with a certain tag (or tags), put the tag name (or a comma-delimited list of tag names) in the Type Options field.

By default, only a single asset can be selected. If you want to be able to select multiple assets, put an asterisk in the Type Options field (after the tag names, if any).

Accessing Related Assets

When you are in an item context (such as on an item page inside a <w:kb:item> block, or in a <w:kb:item:each> loop), you can access the related assets (assuming they are images) as follows:

<w:assets:each>
  <img src="<w:path />" alt="<w:caption>" />
</w:assets:each>

As always, you can include a rendition name in the w:path statement if you want to access a size other than the original (see Creating and Accessing Image Renditions for details.

Another Approach: Start With the Assets

Note that you can also define associations as part of the asset's metadata. For example, when you upload (or update) an asset (uploaded file of any type), you can assign it to one or more categories or tags. So you could, for example:

  • Make a category "chairs"
  • Assign the "chairs" category to all photos of chairs
  • Assign the "chair" tag to each product that is a chair

You can then access all of the chair photos whenever you are displaying a chair product page.

For more details on this approach, see Accessing Images and Other Files.


Add Your Comments

(not published)