Organizing templates in subfolders?

Hi,

is ist possible to organize the templates in subfolders? I want to put all my ajax templates in an ajax subfolder for example.

Like /site/templates/ajax/my-ajax-templates.php

Thank´s for your answer

No, I think that’s not possible at the moment. But you could do a workaround: name all your ajax-templates ajax.php and include a snippet based on uid/some site variable or whatever. Snippets can be organized in subfolders, so calling would be snippet("ajax/" . $page->uid()) for example. The snippet is placed in site/snippets/ajax/your-uid.php

I just found a better way to do this. Sorry for reviving the topic, but I think this is an important feature for bigger websites.

You need to add the next definition to your routing

  array(
    'pattern' => 'folder/(:any)',
    'action'  => function($page) {
              $site = kirby()->site();
              $page = page('folder')->children()->find($page);
              tpl::load(kirby()->roots()->templates() . DS . "folder/$page.php", array('site' => $site,'page' => $page), false);
        },
    'method' => 'GET|POST',
  )

this will work, and you cas use different blueprints for every oage as it loads the right page into the $page variable.

2 Likes