# New addon ModuleLink

**URL:** <https://discourse.getcockpit.com/t/new-addon-modulelink/307>\
**Category:** Addons\
**Created:** [October 1, 2018, 7:20pm UTC](https://discourse.getcockpit.com/t/new-addon-modulelink/307 "2018-10-01T19:20:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [October 1, 2018, 7:20pm UTC](https://discourse.getcockpit.com/t/new-addon-modulelink/307/1 "2018-10-01T19:20:31Z")

</div>

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

> **[raffaelj/cockpit\_ModuleLink](https://github.com/raffaelj/cockpit_ModuleLink)**
>
> Module Link Field for Cockpit CMS. Contribute to raffaelj/cockpit\_ModuleLink development by creating an account on GitHub.

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

![](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/970b7981f1f354d6357fd2fb79077dfca0d0a091.png)

 ![](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/1X/61487a08848021ee344e4e44e3727bc2927a57a1.png)

---

<div class="post-metadata">

**Author:** ![Rozkalns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/rozkalns/32/114_2.png) [@Rozkalns](https://discourse.getcockpit.com/u/Rozkalns)\
**Post date:** [October 8, 2018, 12:49pm UTC](https://discourse.getcockpit.com/t/new-addon-modulelink/307/2 "2018-10-08T12:49:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [October 8, 2018, 3:18pm UTC](https://discourse.getcockpit.com/t/new-addon-modulelink/307/3 "2018-10-08T15:18:30Z")

</div>

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

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

```

or

```auto
{
  "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:

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

```

**pageslink**

field type: collectionlink

options:

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

```

**anotherfilter**

field type: Modulelink

options:

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

```

**multi**

field type: Multiplecollectionlink

options:

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

```

**form**

field type: Modulelink

options:

```auto
{
  "module": "forms"
}

```
