Collection List within Collection List Alternatives

Ed, there’s another approach I’m considering that solves some of these problems, but sacrifices a bit of convenience on the admin side.

Given 2 collections;

  1. Main collection, e.g. Tours
  2. Secondary collection, e.g. Tags, contains full tag data- unique tag Name, plus display Title, Color, Linked page, and a Match string that is the exact Name wrapped in delimiters.

We don’t use a Reference or Multi-Reference field, because of the reference-field-count and collection-within-collection limitations there. Instead, in Tours, we have a plain text field named Tags which uses this format-

,tag1,tag2,tag3,tag4,tag5,

EXAMPLE DATA

Tag #1
Name: 2day
Match: ,2day,
Title: 2 Day Tour
Color: #ff0000

Tag #2
Name: ticket
Match: ,ticket,
Title: Ticket Included
Color: #00ff00

Tag #3
Name: lunch
Match: ,lunch,
Title: Lunch Included
Color: #ff00ff

Tour #1
Name: Hobbiton Movie Set Tour
Tags: ,lunch,2day,ticket,

Then to generate the necessary UI on the “All Tours” page;

  1. In each Tour Collection Item, include a DIV to contain the tags. Within that DIV, or as a custom data property on that DIV, attach that Tour’s tags list, e.g. ,lunch,2day,ticket,
  2. Beneath the Tours Collection, have a separate Tags Collection, which renders all tags exactly as we want them to appear visually, but all are rendered inside of a hidden DIV container.
  3. Using jQuery, find our Tour Collection Item tags list, parse the CSV, and expand each tag by cloning that Tag’s HTML chunk. Basically we’re just duplicating our hidden, rendered Tag HTML wherever it has been referenced.

And on the “Tags” Collection Page, I think we can show all of the correctly tagged tours by showing all Tours in which the Tags field contains the current Tag Match field value. I haven’t tested that though, and there may be some limitation there I haven’t seen yet, in which case we’d need to use jQuery again to delete non-matching Tours.

NB: The reason for the Tags.Match field and the delimiters wrapping the Tours.Tags field, is to support that contains approach without mis-matching similar tags, e.g. lunch and halal-lunch would both match “lunch”.

Advantages - Unlimited tags per tour, styled however you want, ordered however you want. The styling work can be done in the Designer visually.
Disadvantages - programming, and admin training

2 Likes