Community

Example of use of Entity Reference module

I'm delighted at the wonderful help that the Entity reference module has been to my project, and so I thought I would post my simple example of how I used it.

I am developing a Thai language website, and so as well as individual words, I also want to include many phrases which show individual words in the context of larger sentences. For example My son likes elephants. The problem for a language learner is that as soon as you move beyond a single word, it becomes hugely difficult to separate out each of the words in the sentence. Hence the need to be able to know all the underlying words which make up a larger sentence. In this example, the learner of Thai would need to know that My son likes elephants is made up of the 3 words son, to like and elephant. The Entity reference module was exactly what I needed!

My main content type I have called "Media page"; it contains simply a recording of a word or phrase.

Now with the Entity reference module I have added a field called "literal" which is:

  • an Entity reference field
  • links to nodes only of other media pages type, by defining that the link type is "node" of type "Media page"
  • is set to link to the related Entity, so that the user can click on the link
  • is defined to allow "unlimited" quantities of this field within the node so that a media page can have as many sub-words as possible (in the above example this is three: "son", "to like", "elelphants")

Finally I added a little CSS to make the words appear in a row rather than as a list:

.field-item {
display: inline;
margin-right: 20px;
}
nobody click here