# Collectionlink in a singleton

**URL:** <https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403>\
**Category:** Uncategorized\
**Created:** [April 29, 2020, 4:17pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403 "2020-04-29T16:17:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stellar76](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/stellar76/32/588_2.png) [@stellar76](https://discourse.getcockpit.com/u/stellar76)\
**Post date:** [April 29, 2020, 4:17pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/1 "2020-04-29T16:17:36Z")

</div>

I’m pretty new to Cockpit. I created a collection called testimonies with a about 10 entries. I’m trying to import them into a a singleton. i use Collectionlink and then in the code portioni use:  
{  
“link”: “testimonies”,  
“display”: “testimony”,  
“multiple”: false,  
“limit”: false  
}  
all of the other content from the singleton shows up when i fetch it but the Collectionlink for testimonies.

any thoughts?

---

<div class="post-metadata">

**Author:** ![alessandro1992ma](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@alessandro1992ma](https://discourse.getcockpit.com/u/alessandro1992ma)\
**Post date:** [April 29, 2020, 5:20pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/2 "2020-04-29T17:20:56Z")

</div>

```
{
  "link": "testimonies",
  "display": "testymony",
  "multiple": false
}

```

your mistake I think is in the double quotes used

---

<div class="post-metadata">

**Author:** ![stellar76](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/stellar76/32/588_2.png) [@stellar76](https://discourse.getcockpit.com/u/stellar76)\
**Post date:** [April 29, 2020, 5:34pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/3 "2020-04-29T17:34:23Z")

</div>

how’s that possible?

---

<div class="post-metadata">

**Author:** ![alessandro1992ma](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@alessandro1992ma](https://discourse.getcockpit.com/u/alessandro1992ma)\
**Post date:** [April 29, 2020, 6:09pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/4 "2020-04-29T18:09:12Z")

</div>

{  
“link”: “testimonies”,  
“display”: “testimony”,  
“multiple”: false,  
“limit”: false  
}

this is the code taken from your message if you see the quotes are not the correct ones.

Does it work with what I sent you?

---

<div class="post-metadata">

**Author:** ![stellar76](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/stellar76/32/588_2.png) [@stellar76](https://discourse.getcockpit.com/u/stellar76)\
**Post date:** [April 29, 2020, 7:56pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/5 "2020-04-29T19:56:04Z")

</div>

sort of. it only shows 2. i have 5 testimonies in there. the testimonies collection has a testimony and an author. the only thing returned it this:

```
"Testimonies": [
        {
            "_id": "5ea866d33335341af70001c9",
            "link": "testimonies",
            "display": "Lorem Ipsum this is testimony content"
        },
        {
            "_id": "5ea866ba33353419df000336",
            "link": "testimonies",
            "display": "Lorem Ipsum this is testimony content"
        }
    ]
```

---

<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:** [April 30, 2020, 6:00pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/6 "2020-04-30T18:00:40Z")

</div>

> [@alessandro1992ma](#):
>
> your mistake I think is in the double quotes used

This is just the auto conversion from discourse. If you use [fenced code blocks](https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks), you can avoid that conversion and the code is also more readable.

@stellar76 add `"populate": 1` to your api request to populate the linked values to your result. _1_ is the depth. If you want to get collection links inside linked entries, increase that value.

---

<div class="post-metadata">

**Author:** ![stellar76](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/stellar76/32/588_2.png) [@stellar76](https://discourse.getcockpit.com/u/stellar76)\
**Post date:** [April 30, 2020, 7:05pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/7 "2020-04-30T19:05:44Z")

</div>

i added “populate”: 1. it is still showing the first two items in the collection and only testimony as “display”.

---

<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:** [May 1, 2020, 12:16pm UTC](https://discourse.getcockpit.com/t/collectionlink-in-a-singleton/1403/8 "2020-05-01T12:16:24Z")

</div>

I tried to reproduce your setup.

1. Create Collection `testimonies` with a text field `testimony`
2. Create Singleton with collectionlink field `test` with the following options. If you want to link more than one item, use `"multiple": true`.

```json
{
  "link": "testimonies",
  "display": "testimony",
  "multiple": true
}

```

1. Open Singleton form in admin ui, click on “Create link to testimonies”, select them all and save the singleton
2. Api request returns all selected/linked entries
3. with `"populate": 1`, the api request contains not only the display name, but also all other fields from the linked entries.
