Closed oddnavy closed 4 years ago
Yes, you can do this:
'api/<uri:.*>' => function(string $uri) {
return [
'elementType' => craft\elements\Entry::class,
'criteria' => [
'uri' => $uri,
],
'one' => true,
];
},
It is possible to define an element-api endpoint which can retrieve an element by URI and handle nested URIs.
For example, we have an entry with the URI of
/about/our-team
and would like to make an element-api query toapi/pages/about/our-team
or a variation of that.api/products/<uri>
doesn't seem to work (I'm assuming the regex doesn't match the nested path).