Jump to content

LuisM

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

2 Neutral

About LuisM

  • Rank
    Newbie
  1. Yeah, this did the trick... Thank you 🙂 My solution for what I needed this for: public function templateSave($event){ $templateId = $event->arguments(0)->id; $templates = $this->wire('templates'); $template = $templates->get($templateId); $fieldgroup = $this->wire->fieldgroups->get($template->name); $data['name'] = $template->name; foreach($fieldgroup as $k => $v){ $field = $this->wire('fields')->get($k); $data['fields'][] = ['name' => $field->name, 'id' => $k]; } $data = json_encode($data, JSON_PRETTY_PRINT); $file = $this->wire('config')->paths->root.'models/'. $template->name .'.json'; file_put_contents($file, $data); } which would generate something like { "name": "BaseController", "fields": [ { "name": "title", "id": 1 }, { "name": "ControllerEnvironment", "id": 219 }, { "name": "active", "id": 132 }, { "name": "accesspermissions", "id": 197 }, { "name": "accesspermission", "id": 196 }, { "name": "appcompanyname", "id": 125 }, { "name": "appuserreference", "id": 177 }, { "name": "appuserroles", "id": 186 } ] }
  2. Hi there, im a bit lost right now. I added an hook after templates::save which should get the affected template and write its template ID into a JSON. The problem is, the event->object gives me an instance of the templates class. How can I narrow this down to the saved Template and get its ID and fieldgroup?
  3. You could try something quick and dirty in your template file. Before any output check if the $user is logged in on every request and redirect him to the same page if not. This should trigger your login I guess <?php if(!$user->isLoggedin()){ $session->redirect($page->url) } ?>
  4. Thomas, I recently found your module, good job. Right now im thinkering with Electron and making Processwire to serve as a headless CMS. So your module is quite handy. I forked the module on GitHub and made it a little bit more connected to Processwire. To sum things up, I creates a "Endpoint Container" in the page tree where you can add your routes and methods. It still needs to add responding classes to provide content ;) I added a skeleton Class called "Blog" to get all contents under the "Home" Page or a specific Page via ID. I created a Pull Request, maybe you like my approach. https://github.com/Luis85/RestApi
×
×
  • Create New...