Node Referenced Files

The Node Reference module, distributed with the CCK, allows the creation of a field that references another node. Although it may not be initially obvious how this could help us with our need for file management, it can actually be used as a powerful and simple solution.

If we think of some of the node types we've created throughout this hook as wrappers for our media, this solution should become clearer. For instance, we could use a Node Reference to manage Audio nodes, allowing audio clips to be easily associated with articles.

To illustrate how this can be used, we'll pretend that our client The Hog Blog wants its articles to occasionally display videos, and have all posted videos available m a gallery.

To this end, we'll create a video type using the Embedded Media Field. We'll be able to create a simple view for the gallery page that simply displays all videos sorted by creation date. Then the Article content type will contain a node reference to our video.

You'll first need to activate the Node Reference module, which is included with CCK. If you haven't already, create a Video content type with a field named field_video_ reference from Embedded Media Field. Finally, create an Article content type with a Node reference field called Video reference, with a Select list widget type:

Create new field

Field name:

[held. video reference

The machine-readable name of the field. This name cannot be changed.

Label:

[video reference'

A human-readable name to be used as the label for this field in the Article content type.

Field type:

The type of data you would like to store in the database with this field This option cannot be changed.

Widget type: *

[ Select list

The type of form element you would like to present to the user when creating this field in thej^rtVc/e content type.

The Select list widget will display ¡1 list of all tities 0f the referenced node type(s) when creating new c ontent. In many situations, particularly where you expect to have mora than a couple of dozen nodes of that type, the Autotompieie Text Field widget is probably more useful as the c ompiete list of matched nodes can easily become unwieldy. In that case, you would simply type a few characters of the video title, and itwouid appear in a drop-down selection list of suggested similar tides.

Make sure to check the Video box in the Content types that can be referenced section of the Field settings page.

Another useful trick here is to create a view for your reference selection. By opening the Advanced - Nodes that can be referenced (View) fieldset, you'll be able to select a View that will filter the available references. For instance, you might create a View that lists the 20 most recent videos,.and use that View here. That is useful in many production settings, where1 editors don't want to remember the title of a video they might want, don't want to sort through a hundred node titles, and are only working with recent content.

Next go to the Display fields page of the Article type by browsing to Administer | Content management | Content types | Video | Display fields (at ^ISmin/content/ MQd^-type/sideoi/digpiay), and select the desired settings. In our example, we'll set the Label of our Video reference field to <IIidden>, the selector for Teaser to Teaser, and the selector for Full node to Full node. If you've also set the display settings for the Video field of the Video content type appropriately, you'll get a thumbnail or preview-size video for the teaser, and a full-sized video, perhaps with Autoplay, for the full-size video node, and these will be reflected in the reference:

In odio eras, semper et, tempor ac

I Devioad Dev render Edit Track

Aenean ac Odio

Aenean ac Odio

Suspendíase tortor Ipsum, uElemcorper In. lacinia et, mollis vel, erat. Aenean leo justo, imperdíet dictum. tincEdunt non, uitrices sit amet. pede. In non massa sodales nunc tempor condimentum. Ut vestibulum mauris vel tortor. Duis varius elit sed libero, eras gravida, libero non pretlum dignisslm, augue nibh pulvinar sem, sit smet laoreet libero lectus sit amet magna. In hac habitasse plates dlctumst. Aliquam erat volutpat. Aliquam mi mauris, porttitor ut, aliquam posuere blbendum a. pede. Fusee quls nunc. Nulla sed mauris! Fusee posuere dictum nunc?

Suspendíase tortor Ipsum, uElemcorper In. lacinia et, mollis vel, erat. Aenean leo justo, imperdíet dictum. tincEdunt non, uitrices sit amet. pede. In non massa sodales nunc tempor condimentum. Ut vestibulum mauris vel tortor. Duis varius elit sed libero, eras gravida, libero non pretlum dignisslm, augue nibh pulvinar sem, sit smet laoreet libero lectus sit amet magna. In hac habitasse plates dlctumst. Aliquam erat volutpat. Aliquam mi mauris, porttitor ut, aliquam posuere blbendum a. pede. Fusee quls nunc. Nulla sed mauris! Fusee posuere dictum nunc?

0 0

Post a comment