Jump to content


  • Posts

  • Joined

Everything posted by hellomoto

  1. I want to create a fieldtype Fields which in the config can be set as single or multi-value, and optionally filter available options dynamically according to a specified template field (using something like FieldtypeTemplates or FieldtypeSelectExtOption or even FieldtypeText). FieldtypePage can do this by including another page field in the selector, it can be a child dependent on its value... Could anyone just provide me with a starter guide? I'm looking at other modules for insight but ultimately remain lost. Thanks so much.
  2. Never mind this works $manager = new SelectableOptionManager(); $options = "0=Import\n1=Update"; $manager->setOptionsString($f, $options, true);
  3. I have a module that creates a bunch of fields and none of the Options type are saving their values. The options I have set appear in the page editor, however when I go to edit any of these fields the textarea where the options are supposed to be specified is blank. $f = new Field(); $f->set("name", "iu_do")->set("label","Action(s)"); $f->type = wire('modules')->get('FieldtypeOptions'); $f->set('inputfieldClass', 'InputfieldCheckboxes')->save(); $f->options = [0 => "Import", 1 => "Update"]; $f->set("required",1)->set("optionColumns",1); $f->set("tags","-impupd")->set("columnWidth",50)->save(); How do I do this right? Thank you.
  4. I have a module with 'autoload' => 'template=admin'. I need to hook into ProcessPageEdit for editing template=importupdate, and within my hook function add CSS and JS files. I have: public function init() { $this->addHookAfter('ProcessPageEdit::execute', $this, 'addlStyles'); } private function addlStyles(HookEvent $event) { //$page = $event->arguments(0); if($page->template != 'importupdate') return; $css = wire('config')->urls->modules . 'ImportUpdateUltimate/editImportUpdate.css'; $this->config->styles->add($css); } which does nothing.
  5. I've been trying and failing to get this going for quite some time now: Here's what I have so far (current issues to follow): So when I install the module, I go to its admin page to add a new Import/Updater, set a title (I want to set it automatically by title but setting the childNameFormat via API when creating the template doesn't work), and encounter the following issues: Field iu_parent selector is ineffective. The "Mapping" tab does not open, despite the field and template fields' order seeming to be intact. ^ I had the FieldsetClose field ending in _close instead of _END. Please help me get past this first phase. Thank you so much.
  6. Attempting to download AdoptDefaultsFromParents (or any module) in PW3 admin produces the following slew of errors: The site/modules permissions = 755, allow_url_fopen & curl = on. How could this be? Why doesn't the download URL come through properly? I sorely miss the splendid convenience of this capability.
  7. Pierre-Luc: so all else the same, just mailto that email address? cstevensjr I was sending to a gmail email, or just performing the check on save, from another one set up with seemingly correct configuration...
  8. I was afraid you would say that... Any idea offhand as to why it might not?
  9. Anyone have this working on PW3?
  10. I hid/set aside the old /wire/, index.php, and .htaccess, as well as /site/config.php. Debug=1. $config->urls->admin = /pw/, as it's set as. I'm finding that others are encountering a similar issue but haven't found any solution yet, at least none that works for me. Please help, thanks much
  11. I'd tried that, both, now the module won't even actually install. (It creates the page all right, sans process, but the module itself is deactivated immediately.) This has all been since it started saying my request appears to be forged so I can't activate modules as normal, need $config->protectCSRF = false; in the site config.php. For some reason now it works that I've put it in ready() instead... somehow... public function ready() { $pg = $this->pages->get('name=importupdate'); if($pg->process != $this) $pg->setOutputFormatting(false)->set('process', $this)->save(); } but it'll only install after 2 tries. 1st try it does create the page, but inevitably needs another attempt. It was working just fine earlier just as I posted it, that's from my last commit which activated ok and all, I can't believe I've been bothering with this all damn night.
  12. class ImportUpdateUltimate extends Process { public static function getModuleInfo() { return array( 'title' => 'Import &amp; Update', 'autoload' => 'template=admin', 'singular' => false, ); } public function execute() { $addnew = wire('config')->urls->admin . '/page/add/?parent_id=' . wire('page')->id . '&template_id=' . wire('templates')->get('name=importupdate')->id; $output = ' <style>th,td { padding: 2px; } tr { border: 1px solid; } th { font-weight: bold; }</style> <p>Nulla laoreet tristique tristique. Sed elementum justo a nisl elementum sit amet accumsan nisi tempor. Nulla quis eros et massa dignissim imperdiet a vitae purus.</p>'; $rows = ''; foreach(wire('page')->children('include=all') as $iu) { $runnable = '<i class="fa fa-exchange"></i>'; if($iu->is(Page::statusUnpublished)) $runnable = ''; $rows .= '<tr><td><a href="' . $iu->editUrl . '">' . $iu->title . '</a></td><td></td><td><a href="' . $iu->url . '" target="#ajaxiframe">' . $runnable . '</a></td></tr>'; } $output .= '<table><tr><th>Title</th><th>LazyCron</th><th>Run</th></tr>' . $rows . '</table>'; $output .= '<a href="' . $addnew . '">+ New Import/Updater</a>'; return $output; } public function install() { $pg = new Page(); $pg->template = "admin"; $pg->name = "importupdate"; $pg->title = "Import/Update"; $pg->save(); $pg->process = "ImportUpdateUltimate"; $admin = $this->pages->get(2); $pg->set("parent", $admin)->save(); } } That same code used to effectively assign the process module above itself as the page's process upon installing the module. Now it doesn't. How can I make it do so?
  13. to complete uninstall run this: foreach($fields->find('name%=blog_') as $f) { foreach ($f->getFieldgroups() as $fg) $fg->remove($f)->save(); $fields->delete($f); } foreach($templates->find('name%=blog-') as $t) { $templates->delete($t); } foreach($fieldgroups->find('name%=blog-') as $fg) { $fieldgroups->delete($fg); } foreach($roles->find('name%=blog-') as $r) { $roles->delete($r); } //$permissions->delete($permissions->get('name=blog'));
  14. This is in my module's install() function: $f = new Field(); $f->type = wire('modules')->get('FieldtypeSelectExtOption'); $f->set("name", "iu_template")->set("label", "Template"); $f->option_table = "templates"; $f->option_value = "id"; $f->option_label = "name"; //$f->filter('id not in (2,3,4,5)'); $f->set("required",1); $f->set("tags", "-impupd")->set("columnWidth",50)->save(); $f = new Field(); // set to select from template's allowed parents $f->type = wire('modules')->get('FieldtypePage'); $f->set("name", "iu_parent")->set("label", "Parent"); $f->set("derefAsPage",1)->set("required",1); $f->set("findPagesSelector","template!=admin,hasParent!=2"); $f->set("tags", "-impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeOptions'); $f->inputfieldClass = 'InputfieldCheckboxes'; $f->set("name", "iu_actions")->set("label", "Action(s)"); $f->options = ["import" => "Import", "update" => "Update"]; $f->set("tags", "-impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeOptions'); $f->set("name", "iu_uid")->set("label", "Match Field"); $f->description = "Values must be unique."; $options = array(); foreach(wire('fields') as $opt) { $options["{$opt->name}"] = "{$opt->title}"; } $f->options = $options; $f->set("required",1); $f->set("tags", "-impupd")->set("columnWidth",50)->save(); Oddly every time I install the module the second field `iu_parent` says it still needs configuring, without fail; I have to go to the field editor and just save it as it is one time. Anyway the real field in question here is the last, i.e., `iu_uid`. That method of adding options is entirely ineffective, sadly; it adds none at all. What I need is for it to dynamically populate with the fields in the previously selected template's fieldgroup on saveReady. This is possible with page fields, to dynamically populate options based on another field's value. Alternatively I can set up `iu_uid` like so: $f = new Field(); $f->type = wire('modules')->get('FieldtypeSelectExtOption'); $f->set("name", "iu_uid")->set("label", "Match Field"); $f->description = "Values must be unique."; $f->option_table = "fields"; $f->option_value = "id"; $f->option_label = "name"; $f->set("required",1); $f->set("tags", "-impupd")->set("columnWidth",50)->save(); Then I would just need for a hook to filter the options to correspond with the `iu_template` value. Any pro tips/guidance to spare on this subject?
  15. Can you provide an example of the filter function? Here's my field being born: $f = new Field(); $f->type = wire('modules')->get('FieldtypeSelectExtOption'); $f->set("name", "iu_template")->set("label", "Template"); $f->option_table = "templates"; $f->option_value = "id"; $f->option_label = "name"; $f->filter('id not in (2,3,4,5)'); $f->set("required",1); $f->set("tags", "-impupd")->set("columnWidth",50)->save();
  16. Can I delete this somehow I got it with just $rfg = wire('fieldgroups')->get('repeater_iu_map'); wire('fieldgroups')->delete($rfg); though I could swear I'd tried that and so much more
  17. I have a module that creates a repeater field on install: $f = new Field(); $f->type = wire('modules')->get('FieldtypeFieldsetTabOpen'); $f->set("name", "iu_maptab")->set("label", "Mapping"); $f->set("tags", "impupd")->save(); $r = new Field(); $rName = "iu_map"; $r->type = wire('modules')->get('FieldtypeRepeater'); $r->set("name", $rName)->set("label", "Map Fields"); $r->set("tags", "impupd")->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeSelectExtOption'); $f->set("name", "iu_field")->set("label", "Template Field"); $f->option_table = "fields"; $f->option_value = "id"; $f->option_label = "name"; $f->set("tags", "impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeText'); $f->set("name", "iu_value")->set("label", "Source Value Selector"); $f->set("tags", "impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeCheckbox'); $f->set("name", "iu_static")->set("label", "Use Static Value"); $f->set("tags", "impupd")->set("columnWidth",50)->save(); $f = new Field(); $f->type = wire('modules')->get('FieldtypeFieldsetClose'); $f->set("name", "iu_maptab_close");//->set("label", "Mapping"); $f->set("tags", "impupd")->save(); $rfg = new Fieldgroup(); $rfg->name = "repeater_{$rName}"; $rFields = ["iu_field", "iu_value", "iu_static"]; foreach($rFields as $rf) { $rfg->append($this->fields->get($rf)); } $rfg->save(); $rt = new Template(); $rt->name = "repeater_$rName"; $rt->flags = 8; $rt->noChildren = 1; $rt->noParents = 1; $rt->noGlobal = 1; $rt->slashUrls = 1; $rt->fieldgroup = $rfg; $rt->save(); $rpg = "for-field-{$r->id}"; $r->parent_id = $this->pages->get("name=$rpg")->id; $r->template_id = $rt->id; $r->repeaterReadyItems = 3; foreach($rfields as $rf) { $r->repeaterFields = $this->fields->get($rf); } $r->save(); Now I can't uninstall it, on account of a field being used in the fieldgroup created for the repeater -- can't delete that field because it's in the fieldgroup which I am trying and failing to delete: $rf = wire('fields')->get('iu_map'); $rt = wire('templates')->get('repeater_iu_map'); $rfg = $rt->fieldgroup; if($rf) { wire('fields')->delete($rf); wire('fieldgroups')->delete($rfg); wire('templates')->delete($rt); } foreach(wire('fields')->find("tags*=impupd") as $f) { wire('fields')->delete($f); } Please help this is such a bother. The fieldgroup should be deleted before attempting to delete the field itself.
  18. How do I make one of these where the options table is fields, but I only want fields that are in a certain template...? via the API? any way?
  19. Kongondo it's not seeming to fit my needs in this particular case. But it is pretty great, thanks.
  20. So this field requires more than one input/set of options? A base + a dependent? Is there an option to select from fields? like fields from a selected template?
  21. Can I assign InputfieldCheckboxes to a field with FieldtypeOptions?
  • Create New...