Jump to content

hellomoto

Members
  • Posts

    355
  • Joined

Everything posted by hellomoto

  1. 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
  2. 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.
  3. 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?
  4. 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'));
  5. 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?
  6. 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();
  7. 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
  8. 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.
  9. 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?
  10. Kongondo it's not seeming to fit my needs in this particular case. But it is pretty great, thanks.
  11. 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?
  12. Can I assign InputfieldCheckboxes to a field with FieldtypeOptions?
  13. Actually that's because they were all pages, that's done in the admin easily. Kongondo does your module allow for templates and fields as options? fields of templates? Looks like it.
  14. Man I had this working perfectly in a major project I was working on and LOST... for Make (choose from pages of template) and subsequent Model (choose from pages of template under Make). I know it wasn't that complicated... or I couldn't have done it...
  15. I need this field in a template, and then another select field which is dynamically populated with field names/references to those present in the previously chosen template for options. Any tips?
  16. Would anyone here be able and inspired to develop a ProcessWire equivalent to the WordPress plugin WP All Import Pro? or to help me do so? This is what I'm envisioning... Upon installation the module creates an admin page titled "Import & Update". On the module config page you can specify allowed templates to run this on, otherwise allowing any. Include the following PHP libraries: hQuery for web scraping, Csv for CSV handling, and Parser for XML. Create template "import-update". On the "Import & Update" page, a list of current import/updaters will be displayed (0 initially), each with corresponding links to "edit" or "run". When you "Add New", this be the "import-update" template (with all module-specific fields tagged "impupd"): title destination (req.): parent, template source (req.): type (web, csv, xml) location (url, file, text) if web: opt. index URL & link selector, + paginator selector if csv: opt. ignore 1st row if xml: req. individual item node xpath actions (check): import (if none matching UID) update (if matching UID & field values differ) save() [req. here in flow] map (repeater): input (select fields from specified template to affect) intake (corresponding DOM selectors / CSV col. letters/headers / xpath per field) (req.) UID (unique ID; field reference to compare against, from selected input fields) (req.) Lazy Cron interval Scripts can be run via the import-update template; keep logs; show preview (iframe/ajax) for manual runs. ...
  17. I want to write a quick little module that regenerate all images in /site/assets/files/ on request. I figure I'll just have a button on the module configuration page to run the script. So do I start it out like so?: class ImgRegen extends WireData implements Module {} singular=true, autoload=false. Sound right so far? Then how do I add this button to the config page to run the script? Need I make it a native PW field, since it doesn't store any data? Thank you all
  18. In my page editor only the map is showing for the field, no inputs. PW 2.7.2
  19. Ok gotcha, I just noticed it screwing up again. It's included now and seems to help the situation. Thank you very much
  20. It's weird if I refresh the page it doesn't seem to do any good unless I reload via clicking the site title. BUT thank YOU flydev, that seems to be the trick indeed! Good lookin' out. (If anyone does observe my layout still misbehaving please do inform me.)
×
×
  • Create New...