Hey!
I wanted to know if it’s possible to get singletons by slug or another field?
right now I get the singletons by this code, but some time the url not the some as the name
This is not possible by default. If you want to filter them, use collections instead.
But you could create a custom api endpoint and fiddle with the results:
<?php
// custom api endpoint in `/config/api/singletons/find.php`
// Your Singletons with a field named "title"
// Search all Singletons with the title "test"
// tested with SQLite - I don't know, if it works with Mongo, too
$options = [
'filter' => [
'val.title' => 'test',
],
];
$singletons = $this->storage->find('singletons', $options);
return $singletons;
This solution is for cockpit v1 (or 0.x), like most of the threads in this forum. Can’t help here because I stopped using Cockpit after the rewrite to v2.