3

Would like to be able to handle requests for structured requests so that it may be handled in one endpoint

    about.json
    about/the-team.json
    about/contact/london.json

Presumably a form of regex would be required for this to work? Contemplating:

    pages/about.json
    pages/about/the-team.json
    pages/about/contact/london.json

All though how would you prepare a check for 'pages' as your first node?

Currently have this but not fees able.

   '<slug:{slug}>*.json' => function($slug) {

thanks

2

Quite a simple solution set the criteria to uri and you just pass the endpoint as is as a catch all.

$normal =  preg_replace('/.json/', '', craft()->request->path);
return [
        'endpoints' => [
            craft()->request->path => [
                'elementType' => 'Entry',
                'criteria' => ['uri' => $normal],
                'first' => true,
                'transformer' => new DetailTransformer(),
            ],
        ]
    ];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.