Iain Urquhart

The Selectatron

Buy Now →

The Selectatron Fieldtype

This fieldtype for EE2 is a one to many relationship tool, on a shoestring.

The Selectatron lets you select entries from multiple channels, and store their entry ids in a 12|22|44|45 format. Sporting a drag & drop interface for ordering selections — entry ids are stored in your selection order.

It also lets you store the selected entries as native EE relationships, so that you can use the reverse_related_entries tag to work entries from the other direction.

Selectatron screenshot

The output from the field is primarily for use in embeds to templates with exp:channel:entries tags utilising the fixed_order parameter.

Example Usage

Say you had a channel for storing content for sidebar modules around your site. You want your publisher to be able to select from a list of available modules (which are EE entries), and also allow the publisher to choose the order they are displayed in.

With this fieldtype, you can do just that. Each selection from the user is stored in a 12|22|44|45 format, so you can simply pass this to your embedded template, which has a regular exp:channel:entries tag and use the fixed_order parameter to control the order.

For example, in your parent template

{exp:channel:entries channel="news"}
	<h3>{title}</h3>
	{main_article}
	{if my_selectatron_field}
	{embed=".includes/sidebar_modules" entries="{my_selectatron_field}"}
	{/if}
{/exp:channel:entries}

Then, within your .includes/sidebar_modules template, you’d output the entries using the following code:

{exp:channel:entries 
	channel="sidebar_modules" 
	fixed_order="{embed:entries}" 
	dynamic="no"}
	{title}
	{whatever_fields_you_want}
{/exp:channel:entries}

The fieldtype has a drag drop interface for ordering selections, and entry ids are stored in your selection order. Storing the relationship data is optional, and for the time being is only available using the reverse_related_entries tag. The method above is essentially the same as the {related_entries tag} which won’t work due to the way the data is being stored.

Installation

  1. Extract the package and upload the contained folders to their corresponding folders on your EE install.
  2. Activate the fieldtype
  3. Configure the channels available to publishers when creating your Selectatron field

↑ Back to top