How do I retrieve the allowed templates when hooking on processPageAdd::getAllowedTemplates ?
<?php
class AllowedTemplates extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'AllowedTemplates',
'version' => 1,
'singular' => true,
'autoload' => true
);
}
public function init() {
$this->addHookAfter('ProcessPageAdd::getAllowedTemplates', $this, "allowedTemplates");
}
public function allowedTemplates($event) {
$pid = wire("input")->parent_id;
if(!(int)$pid) return;
$parent = wire("pages")->get($pid);
if(!$parent->id) return;
// should be made dynamic, but I don't know how to retreive the templates array !!!
$templates = wire('templates')->find("name=basic-page|sitemap");
$event->return = $templates;
}
}