Martijn Geerts Posted August 20, 2013 Share Posted August 20, 2013 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; } } Link to comment Share on other sites More sharing options...
Soma Posted August 20, 2013 Share Posted August 20, 2013 $templates = $event->return; ... since the method returns the templates 2 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted August 20, 2013 Author Share Posted August 20, 2013 Now it becomes clear... (that I didn't think of that before)... You're the best ! TNX Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now