Search the Community
Showing results for tags 'module developement'.
-
Hi, Thanks again for great CMS. I was trying to create a module that can create a new template file and fields. Here is my module script: class NewsPager extends WireData implements Module{ public static function getModuleInfo() { return array( 'title' => 'News pager', 'version' => 001, 'summary' => 'News pager testing!', 'singular' => true, 'autoload' => true, ); } public function init() { //todo add some listeners } /** * Install the module * */ public function ___install() { // new fieldgroup $fg = new Fieldgroup(); $fg->name = 'new-template9'; $fg->add($this->fields->get('title')); // needed title field $fg->add($this->fields->get('body')); // needed title field $fg->save(); // new template using the fieldgroup $t = new Template(); $t->name = 'new-template9'; $t->filename=$this->config->paths->templates . 'news-pager-index.php'; $t->fieldgroup = $fg; // add the fieldgroup $t->save(); } /** * Uninstall the module * */ public function ___uninstall() { $templateNeeded = $this->templates->get("new-template9"); if ($templateNeeded->getNumPages() > 0) { throw new WireException("Can't uninstall because template been used by some pages."); }else { wire('templates')->delete($templateNeeded); } } } The module works fine. But when I try to create pages by using newly created template, in that case the view link is not appearing. Is there any property that I should use for template creation to get view link to be worked. Thank you