![](http://processwire-forums.s3.us-west-2.amazonaws.com/set_resources_6/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
cosmicsafari
Members-
Posts
80 -
Joined
-
Last visited
Everything posted by cosmicsafari
-
Form Builder Query Regarding Uploaded Files In Emails
cosmicsafari replied to cosmicsafari's topic in Modules/Plugins
Figured this might be useful for others. Turns out it was something to do with the version I was running. I downgraded the Form Builder plugin from 3.0.1 to 3.0.0 and the links in the administrator emails worked as expected.- 1 reply
-
- form builder
-
(and 1 more)
Tagged with:
-
Form Builder Query Regarding Uploaded Files In Emails
cosmicsafari posted a topic in Modules/Plugins
Hi All, Just a quick question, if a form has an upload field should there be a working link in the subsequent email which allows you to view the uploaded file? As it stands only the name and size of the file appears in the email although viewing the source it appears wrapped in anchor tags, albeit without any href attribute. I'm not sure if this is the correct result or if I have somehow managed to cause this and there should be a working link to the uploaded file.- 1 reply
-
- form builder
-
(and 1 more)
Tagged with:
-
Abort module Uninstall on condition
cosmicsafari replied to cosmicsafari's topic in Module/Plugin Development
That works a treat, thanks man! -
Hi all, I have a module which creates numerous fields, pages etc. I would like to disable the ability to uninstall the module if any of the generated pages have children, as a mistaken uninstall could really mess up any website which is using it. Im curious about what is the best way to achieve this, currently I have some like: public function ___uninstall(){ error_log('---- UNINSTALL!! ----'); //check to see if any config pages have been added and abort uninstall if true //to avoid uninstalling and losing any work which has been done up to this point. if($this->canWeUninstall()) { //remove pages $this->deletePages($this->cPages->getPages()); //remove templates and field groups $this->deleteTemplates($this->cTemplates->getTemplates()); //remove repeaters $this->deleteRepeaters($this->cRepeaters->getRepeaters()); //delete fields $this->deleteFields($this->cFields->getFields(), $this->cRepeaters->getRepeaters()); } else { error_log('Uninstall aborted because config settings exist!'); $this->error('Whoops! Module cant be uninstalled as it appears to be in use.'); return; } } This works in the sense that it doesn't remove any of the generated content, which is good as it wont break the website. However it still shows the module as uninstalled, I can achieve what i'm looking for by replacing 'return' with 'die' but that results in a white page and looks rather rubbish so its not really a great solution. I would imagine there must be a better way to achieve this, any thoughts? Would it be possible to do this check via a hook before uninstallation and abort before we get to the point of running the uninstall() method, as I imagine that is what updates the DB to turn the module off so to speak?
-
Setting a fields Selectable Pages option via the API
cosmicsafari replied to cosmicsafari's topic in API & Templates
public function fieldGroupOverrides($name, $overrides){ foreach($overrides as $key => $field){ if (is_array($field)) { error_log('==> Override Field: ('.$key.')'); $t = wire('templates')->get($name); $fg = $t->fieldgroup; $f = $fg->getField($key, true); //All Fields, override label if(isset($field['label'])) { $f->label = $field['label']; error_log('===> Override Label Success! ('.$key.') -> ('.$field['label'].')'); } //Page Field, overide selectable pages if(isset($field['parent_of_selectable'])){ error_log('===> Override Parent of Selectable'); $parent = wire('pages')->get('name='.$field['parent_of_selectable']); $f->set('parent_id', $parent->id); error_log('===> Override Success! Parent of Selectable = ('.$field['parent_of_selectable'].')'); } wire('fields')->saveFieldgroupContext($f, $fg); } } }- 8 replies
-
- fieldtypepage
- selectable
-
(and 3 more)
Tagged with:
-
Setting a fields Selectable Pages option via the API
cosmicsafari replied to cosmicsafari's topic in API & Templates
I tried using $f->set('parent_id', $parent->id); But I get a warning on the page This field needs to be configured before it can be used.- 8 replies
-
- fieldtypepage
- selectable
-
(and 3 more)
Tagged with:
-
Setting a fields Selectable Pages option via the API
cosmicsafari replied to cosmicsafari's topic in API & Templates
This was what I ended up at and it seems to work ok even if it is a bit hacky. $sql = "SELECT data FROM fields WHERE id=:fieldid"; $query = wire('database')->prepare($sql); $query->bindValue(':fieldid', $f->id); $query->execute(); $data = $query->fetchAll(); $parts = json_decode($data[0][0],true); $parts['derefAsPage']='0'; $parts['collapsed'] = '0'; $parts['parent_id'] = $parent->id; $parts['labelFieldName'] = 'title'; $parts['inputfield'] = 'InputfieldSelect'; $data = json_encode($parts); $sql = "UPDATE fields SET data=:data WHERE id=:fieldid"; $query = wire('database')->prepare($sql); $query->bindValue(':data', $data); $query->bindValue(':fieldid', $f->id); $query->execute();- 8 replies
-
- fieldtypepage
- selectable
-
(and 3 more)
Tagged with:
-
Setting a fields Selectable Pages option via the API
cosmicsafari replied to cosmicsafari's topic in API & Templates
So from messing around in the database it looks like the when you manually select a parent under the 'Selectable Pages' section and save, it adds "parent_id":X," to the 'data' cell for the field in questions record within the fields table. In context {"tags":"Page-Multi-Select","derefAsPage":0,"collapsed":0,"parent_id":1,"labelFieldName":"title","inputfield":"InputfieldSelect"} So in theory is there any reason why I can't just update the database directly without going through the API? Seems hacky but still can't find any examples of being able to do it through the API.- 8 replies
-
- fieldtypepage
- selectable
-
(and 3 more)
Tagged with:
-
Hi all, I am creating a page field (field of type FieldtypePage) via the API, however im still trying to find some documentation as to how I would go about setting the Selectable Pages for said field using the API. From what I have found it looks like it involves the use of, albeit this looks like a getter rather than a setter: $field->getInputfield($page) Which looks like it would make sense if I wanted to specify the selectable pages by a parent page, but what if I wanted to specify it by say a template?
- 8 replies
-
- fieldtypepage
- selectable
-
(and 3 more)
Tagged with:
-
Can a template have multiple field groups?
cosmicsafari replied to cosmicsafari's topic in API & Templates
Hmm so I edited my code to test this an it appears that no would be the answer. It appears that you can't assign multiple as it will just overwrite the existing field group for that template. -
Selecting a previously created Field Group
cosmicsafari replied to cosmicsafari's topic in API & Templates
Im an idiot, turns out I had already figured this out previously somewhere else among the code for the same module! Anyway for anyone wondering I managed to retrieve them with: $fg = wire('fieldgroups')->get('field-group-name'); -
Hi all, Just another quick question, how would I select a previously created field group so that I can add it to a template using the API? All the examples I have seen thus far are creating the field group and adding it to a template at that point, I would rather create all my field groups beforehand and then assign them to their templates in batch.
-
Hi all, Just a quick question before I jump in and inevitably break the module I am working on. Is it possible to assign multiple field groups to a single template via the api? I am creating a whole bunch of fields, templates and pages on the fly at install and being able to assign multiple field groups to a template would be quite advantageous.
-
Magic, thanks!
-
Hi all, I am working on a module which creates templates, fields & pages upon install. I have ran into an issue where I have a numerous fields which I would like to override their labels depending on the template they are used in. Is it possible to do this dynamically via API at the point where I am creating the field group and template using the API. The following is the code which I am using at the moment. foreach($templatesArray as $name => $cTemplate) { if(array_key_exists('fieldGroup',$cTemplate)) { $fg = new Fieldgroup(); $fg->name = $name . '-fg'; foreach ($cTemplate['fieldGroup'] as $field) { //possibly at this point? $fg->add($this->fields->get($field)); } $fg->save(); } $t = new Template(); $t->name = $name; $t->fieldgroup = $fg; $t->noChildren = 1; $t->setIcon($cTemplate['icon']); $t->save(); } Is this even possible?
-
Hi All, I am working on a module at the moment which in theory will create a few simple fields, templates and pages which will all be linked together. All is going well so far, I have it generating said fields, templates and pages, however I would like to also set the pages sort order and icon programmatically at this stage also. I have yet to see any documentation or any other threads where this has been brought up, is it even possible programmatically without interacting with the database directly? This is the snippet which is generating my pages on the fly at the moment. foreach($arrayOfPages as $name => $page) { $p = new Page(); $p->template = 'page'; $p->name = $page['URL']; $p->title = $name; $p->parent = wire('pages')->get('name='.$page['parent']); //is it possible to set the icon and sort order at this point, before saving? $p->save(); }
-
Admin login 404's after editing Template access
cosmicsafari replied to cosmicsafari's topic in General Support
Seems like Tom. was correct, the problem wasn't with the admin template after all. I forgot that I had built a module which would limited who could access pages based on the admin template depending on their roles. It appears that in creating the new role it totally messed with the logic of the module, I have since updated the module and I can log back in again as expected. -
Admin login 404's after editing Template access
cosmicsafari replied to cosmicsafari's topic in General Support
Luckily there is a front facing log in form, so I managed to add the superuser role to a normal account and log in that way. Will update when I figure out what it was I had changed and how to undo it, figure it might be useful for others in future. -
Scratch that I found them under 'field_roles'
- 1 reply
-
- 1
-
-
Hi All, Which table within the database stores a users assigned roles?
-
Thanks!
-
Hi All, I was playing around with the settings for various templates as I had created a new role and have inadvertantly locked myself out. I changed some of the settings on the Admin template, so I assume this is what has caused the lock out. I have direct access to the database but I have no idea what I would need to change in it to regain access. Probably also worth mentioning that all the existing pages are still accessible, but /processwire throws a 404.
-
Hi all, Just wondering if its safe to delete the content of the cache table manually within the database?