Collectionlink in a singleton

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?

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

your mistake I think is in the double quotes used

how’s that possible?

{
“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?

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"
        }
    ]

This is just the auto conversion from discourse. If you use fenced 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.

2 Likes

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

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.
{
  "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.