Content representation template in kirby registry -> how?

How can I include my content representation template test.json.php in a plugin via the kirby extension registry?

I have tried $kirby->set('template', 'test', __DIR__ . '/templates/test.json.php');but this doesn’t seem to work when I visit site.tld/en/test.json: I’m being 404 redirected to the error page.

Edit: Just stating the obvious that /content/test/test.en.txt exists :slight_smile:

Think you have to register the standard template first:

<?php

$kirby->set('template', 'test', __DIR__ . '/templates/test.php');
$kirby->set('template', 'test.json', __DIR__ . '/templates/test.json.php');

You’re right @texnixe. I can confirm this works then. Thank you!

Was this in the docs somewhere? Would be nice to add it, if it wasn’t. :wink:

Don’t think it’s in the docs, just thought it could be that way. I’ve added an issue on GitHub to include it in the docs.

1 Like