Return theme template from custom controller


Our site would need to access 3rd party site to validate a code and if the code is valid then render a page with information from 3rd party.

User would go /secret/{code} and if the code is valid then render templates/secret/code/index.html with variables.

I have created a controller: php please make:controller-helper Secret and added route: secret/{code}: [email protected]

The questions are: 1. how I can return the template from public function validateCode($code) after I have done the 3rd party check? I would like to have it like having route like this:

routes: {
    template: secret/code/index
    load: /secret

So it uses the secret/code/index template and data from secret (+few variables passed from the custom controller

  1. how to access the $code variable on the controller? On Laravel it works having it as public function validateCode($code) but on statamic i'm getting "Too few arguments" error

Any ideas?

Note: this form post has something related to my problem but I cant use a tag as it needs 3rd party check

Edit: This problem is for statamic v2.

in v3, you could do this:

return (new \Statamic\View\View)
        ->with(['title' => 'Example Title']);

This seems to be what I'm looking for v2

>>>>>>> Unanswered <<<<<<<
3 Replies