New addon ModuleLink


#1

I wrote an addon to link complete collections, singletons and forms:

Code reviews and suggestions are very welcome. Please discuss about it here or in the addon issues.


#2

Can you explain why this plugin might be useful and what are differences in your screenshot between modules, anotherfilter, forms and pageslinks, multi?


#3

Of course. With collectionlinks you can link and populate single items. With modulelinks you can link and populate complete collections (or singletons or forms).

Example:

You have a collection with images. Each entry is an image with a description and some meta data. In another collection “pages” you can link a single image with a collectionlink or all images with a modulelink.

In the backend there is no preview for all the content of a collection for now. I have some other points on my to do list before I can work on it. But if you call your collection through the api with

{
  "populate":"1", // populate collectionlinks 1 level deep
  "populate_module":"1" // populate modulelinks 1 level deep
}

or

{
  "populate":"qwe", // simple hack to trigger populate function without populating collectionlinks
  "populate_module":"2" // populate modulelinks 2 levels deep
}

all entries of the collection will be populated.

Explanation of field names in screenshot

The names were just small reminders in a test collection. I was too lazy to build a new one when I published the screenshots.

module

field type: modulelink

options:

{
  "module": "collections",
  "filter": {
    "type": "foo",
    "color": "#FFCE54"
  }
}

pageslink

field type: collectionlink

options:

{
  "link": "products",
  "display": "title"
}

anotherfilter

field type: Modulelink

options:

{
  "module": "singletons",
  "filter": {
    "color": "#FFCE54"
  }
}

multi

field type: Multiplecollectionlink

options:

{
  "links": [
    {
      "name": "pages",
      "display": "title"
    },
    {
      "name": "products",
      "display": "title"
    }
  ]
}

form

field type: Modulelink

options:

{
  "module": "forms"
}