-
Posts
362 -
Joined
Everything posted by hellomoto
-
Never mind this works the mmpid was 0 had wrong template name. <?php $mmpid = wire('pages')->get('template.name=mamo_makemodel')->id; echo $mmpid.'<br><br>'; // Manufacturers: importCSV(__DIR__.'/manufacturers.csv', 'mamo_manufacturer', $mmpid); // Models: importCSV(__DIR__.'/models.csv', 'mamo_model', 0, $mmpid); function importCSV($filepath, $template, $parent_id = null, $grandparent_id = null) { $csv = array_map('str_getcsv', file($filepath)); array_walk($csv, function(&$a) use ($csv) { $a = array_combine($csv[0], $a); }); array_shift($csv); # remove column header //echo '<pre>'; print_r($csv); echo '</pre>'; foreach($csv as $r) { $p = new Page(); $p->name = wire('sanitizer')->pageName($r['title']); $p->template = $template; if($parent_id !== 0||null) { $p->parent_id = $parent_id; } elseif($parent_id == 0||null) { //$parent = wire('pages')->get('title=' . $r['parent']); //echo $parent.' ';// echo $r['parent'].' '; $parent = wire('sanitizer')->pageName($r['parent']); $parent = str_replace('---','-',$parent); echo $parent.' '; echo $grandparent_id.'gp '; $parent = wire('pages')->get('title=' . $r['parent'] . ', parent_id=' . $grandparent_id)->id; echo $parent.'p '; $p->parent_id = $parent; unset($r['parent']); } $p->save(); foreach($r as $k=>$v) $p->$k = $v; $p->save(); echo '<br>'; } }
-
I have the following import script being included in the homepage template file: <?php $mmpid = wire('pages')->get('template.name=makes')->id; // Manufacturers: $file = __DIR__.'/manufacturers.csv'; importCSV($file, 'mamo_manufacturer', $mmpid); // Models: $file = __DIR__.'/models.csv'; importCSV($file, 'mamo_model', 0, $mmpid); function importCSV($filepath, $template, $parent_id = null, $grandparent_id = null) { $csv = array_map('str_getcsv', file($filepath)); array_walk($csv, function(&$a) use ($csv) { $a = array_combine($csv[0], $a); }); array_shift($csv); # remove column header //echo '<pre>'; print_r($csv); echo '</pre>'; foreach($csv as $r) { $p = new Page(); $p->name = wire('sanitizer')->pageName($r['title']); $p->template = $template; if($parent_id !== 0||null) { $p->parent_id = $parent_id; } elseif($parent_id == 0||null) { //$parent = wire('pages')->get('title=' . $r['parent']); //echo $parent.' ';// echo $r['parent'].' '; echo $grandparent_id.' '; $parent = wire('pages')->get('title=' . $r['parent'] . ', parent_id=' . $grandparent_id)->id; echo $parent.' '; $p->parent_id = $parent; unset($r['parent']); } $p->save(); foreach($r as $k=>$v) $p->$k = $v; $p->save(); echo '<br>'; } } Output = Why is it running the ELSE when the condition for the IF is met? (the first 9 lines) All 14 models (lines past 9) are created under the first manufacturer. I've been messing with it, been able to get them to display the page IDs proper at one point for the models but still there's the standing issue of all of them being created under the first manufacturer nonetheless and also the ELSE running despite not being a condition of ELSE. What's up please...
-
I have a module that I am using to create an image field like so: $mf[] = [[ 'tags' => $tag, 'name' => $pre.'logo', 'type' => wire('modules')->get('FieldtypeImage'), ],[ 'label' => 'Logo', 'columnWidth' => 50, 'inputfieldClass' => 'InputfieldImage', ]]; Yet upon its creation, initially, when I try creating a page of a template including it, it says that the field must first be configured. Once I go and save the field as-is, everything's honkey dory. It's just an annoyance, with every image field. I figured it would be the required inputfieldClass field field, but as you can see, that's included up in there, and it's still not good to go off the bat.
-
It's shorthand for creating new fields, templates, fieldgroups, and pages via the API. See bb for example usage.
-
RewriteEngine on RewriteBase / RewriteRule ^index.php$ / [NC,R,L] RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ RewriteRule . %1/%2 [R=301,L] # mask primary domain subdir. location RewriteCond %{HTTP_HOST} ^(www\.)?audino\.us$ [NC] RewriteRule ^(.*)$ /audino\.us%{REQUEST_URI} [L,NC,QSA] The above seems effective overall, except that (www.)?example.com/example.com(.*) need hide that tricky subdirectory from the URI. Also I need to know how to either force or omit the www. prefix while also pointing to & hiding the subdirectory serving the site.
-
Christophe: that line #11 you mention is commented out in [public_html/].htaccess. The www I hadn't yet decided whether to force or omit. How do I prevent / from rendering the URL as /audino.us/?
-
Now I have RewriteEngine on RewriteBase / RewriteRule ^index.php$ / [NC,R,L] # remove double/more slashes in url RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ RewriteRule . %1/%2 [R=301,L] RewriteCond %{HTTP_HOST} ^(www\.)?audino\.us$ [NC] #RewriteBase /audino.us RewriteRule !^audino\.us/ /audino\.us%{REQUEST_URI} [L,NC] # above 2 lines same effect and in site/ready.php $config->urls->root = '/'; thus: ^(www.)?example.com => example.com/example.com/ ^(www.)?example.com/pw, ^(www.)?example.com/pw/ => example.com/pw/ How to remedy this? Also I am still unable to login; I've tried resetting the password via API in case I had it wrong.
-
I have RewriteBase / in the PW htaccess, so / but: / => example.com /pw => example.com/example.com/pw/ /pw/ => example.com/pw/ www. => www.example.com/example.com/ (root links also = "", as opposed to www.example.com How can I fix this? root .htaccess = RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(www\.)?example\.com/?(.*)$ http://example.com/$1 [R] RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /example.com/$1 [L,QSA] oh and so much for hiding the domain I did just because you said but you didn't but that's a ok
-
I have web hosting with the following .htaccess en root, to point it to a subdirectory "audino.us", wherein I have PW installed: RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?something.com$ RewriteCond %{REQUEST_URI} !^/something.com/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /audino.us/$1 RewriteCond %{HTTP_HOST} ^(www.)?something.com$ RewriteRule ^(/)?$ something.com/index.php [L] RewriteCond %{HTTP_HOST} ^(www.)?something.com$ RewriteRule ^(/)?$ something.com [L] However when I go to audino.us/pw to access the admin, it becomes audino.us/audino.us/pw, and doesn't allow me to log in. How do I render the above to be recursive (?), i.e., to apply to all subordinate URLs? Is this to be done within the .htaccess in /audino.us, or in the root .htaccess above? Please help, I can't log in. Thanks much.
-
Updated bulkup(): private function bulkup($form) { if($this->input->post->import) { $files = $this->input->post->bla_upload; if(!count($files)) { return "No files were found."; }else{ $list = ''; foreach($files as $f) { $list .= $f . PHP_EOL; } return count($files)."\n".$list; } } } Like this it returns: when I upload just 1 file... it counts 2... and there is (and was before) a directory for the process page's ID in site/assets/files, but it remains empty still. I'm blue, need a clue.
- 1 reply
-
- inputfield
- process
-
(and 1 more)
Tagged with:
-
I have a process module like so: public function execute() { $output = 'mad music archive/bulk uploadability management'; $form = $this->makeForm(); if($this->input->post->import) $output .= $this->bulkup($form); else $output .= $form->render(); return $output; } public function ___install() { $mkr = new ImportShorthand(); $p = [[ 'template' => 'admin', 'parent_id' => 2, 'name' => self::PGNAME, 'title' => '[Blaudio] Mgmt', ],[ 'process' => $this, ]]; $mkr->newPage($p); } public function ___uninstall() { $wp = wire('pages'); $pg = $wp->get('template.id=2, parent.id=2, name='.self::PGNAME); if($pg->id) $wp->delete($pg, true); } private function bulkup($form) { if($this->input->post->import) { $form->processInput($this->input->post); return; if(!$form->getErrors()) { $files = $form->get("bla_upload")->value; if(count($files)) { return count($files);/* $bulkload = $bulk_upload->first(); //$bulkload->rename("address-import.csv"); $bulkloadname = $bulkload->filename;*/ }else{ return "No files were found"; } //$this->session->redirect("../edit/?id=$list_id"); } } } private function makeForm() { So far, returning early in the bulkup() function, submitting the form with an acceptable file results in this error message: Upon reloading the page (afresh, without the submitted data; i.e., clicking its link in the nav) this error is displayed within the upload field: I'm assuming this is due to the fact that this is a process page. How do I ensure temporary storage? My goal ultimately is to insert a new page for each valid file. Thanks much in advance.
- 1 reply
-
- inputfield
- process
-
(and 1 more)
Tagged with:
-
I cannot manage to delete this page upon uninstallation of a Process module I have that was working previously. I thought the only difference would be that I added `namespace ProcessWire;` to the start of the module PHP, however I've tried without it and still I get It is an admin page. Right now I have $get = 'template=admin, parent!=trash, name=importall, include=all'; $gp = wire('pages')->get($get); if($gp->id) { wire('log')->save($log, "$gp->id".get_class($gp).__NAMESPACE__); $gp->delete(); if(!wire('pages')->get($get)->id) wire('log')->save($log, "Deleted Imports page."); } previously $gp = $this->pages->get('template=admin, parent!=trash, name=importall'); if($gp->id) { $this->pages->delete($gp, true); $this->log->save($log, "Uninstalled ". get_class()); } Why will it no longer delete? I can't even do so by the GUI.
-
Actually it's even doing this when I just save a published page without unpublishing it, I don't think I'd even tried that before
- 5 replies
-
- processpageedit
- render
-
(and 2 more)
Tagged with:
-
For some reason when I unpublish an already-published page, even of a template other than the specified 'importer', all its fields are cleared on page render. How do I understand and remedy this? Peace & thanks public function init() { $this->addHookAfter('Page::render', $this, 'renderEditor'); } protected function renderEditor(HookEvent $event) { $here = $event->object; $page = $this->pages->get($this->input->get->id); //$this->log->message($page->template.$here->process); return; if ($here->process != 'ProcessPageEdit' && $page->template != 'importer') return; $css = $this->config->urls->ProcessImportAll . 'ass/ProcessPageEdit_importer.css'; $event->return = str_replace("</head>", "<link rel='stylesheet' type='text/css' href='{$css}'/>\n</head>", $event->return); $field = wire('fields')->get('name=pi_template'); if (count($field->templateTypes)>0) { $templates = $field->templateTypes; } else { $templates = []; foreach (wire('templates') as $tpl) $templates[] = $tpl->id; } sort($templates); //$tplTypes = json_encode($templates); $templatesFields = $this->getTemplatesFields($templates); $templatesFields = json_encode($templatesFields); $js = <<<EOT <script> $(document).ready(function(){ if (!document.getElementById('Inputfield_status_2048').checked) { $('#ProcessPageEditContent *').prop('disabled',true); } else { var all = $templatesFields; var sel = '#Inputfield_pi_template option[selected="selected"]'; var tpl = getTpl(); var arr = all[tpl]; var def = '<option value=""></option>'; $('#Inputfield_pi_match').prepend(def); filterFields(tpl); $('#wrap_Inputfield_pi_template .asmListItem .asmListItemRemove').click(clearFieldOptions); $('#Inputfield_pi_template').change(function() { var on = $(this).find('option[selected="selected"]')[0]; if (on !== undefined) { tpl = on.value; //console.log('clicked ' + tpl); filterFields(tpl); } else { tpl = null; clearFieldOptions(); } }); function filterFields(t) { if (t != null) { $('#Inputfield_pi_match').prop('disabled',false); arr = all[t]; //console.log(arr); $('#Inputfield_pi_match option').each(templateFieldOptions); $('#wrap_Inputfield_pi_fieldmap select option').each(templateFieldOptions); $('#_Inputfield_pi_maptab').click(function() { //$('#wrap_Inputfield_iu_fieldmap select option').each(templateFieldOptions); }); } else { clearFieldOptions(); } } function getTpl() { if ($(sel).length>0 && $(sel)[0].value) { var tpl = $(sel)[0].value; } else { var tpl = null; } return tpl; } function templateFieldOptions() { var val = parseInt(this.value); if (!arr.includes(val) && val>0) { //console.log(val + ' ' + arr); $(this).prop('selected',false); $(this).prop('disabled',true); } else { if (arr.includes(val) && val>0) { //console.log(tpl); $(this).prop('disabled',false); } } } function clearFieldOptions() { $('#Inputfield_pi_match').find('option[value=""]').first().prop('selected',true); $('#Inputfield_pi_match').find('option[value!=""]').each(function() { $(this).prop('disabled',true); }); $('#Inputfield_pi_match').prop('disabled',true); $('#wrap_Inputfield_pi_fieldmap select').find('option[value=""]').first().prop('selected',true); $('#wrap_Inputfield_pi_fieldmap select').find('option[value!=""]').each(function() { $(this).prop('disabled',true); }); $('#wrap_Inputfield_pi_fieldmap select').prop('disabled',true); } } }); </script> EOT; $event->return = str_replace("</body>", "$js</body>", $event->return); //$this->filterFieldFields($event); }
- 5 replies
-
- processpageedit
- render
-
(and 2 more)
Tagged with:
-
Done did it: public function init() { $this->addHookAfter('Page::render', $this, 'styling'); $this->addHookAfter('Page::render', $this, 'filterFieldFields'); } protected function styling(HookEvent $event) { $page = $event->object; $edid = $this->pages->get($this->input->get->id); if(!($page->process = 'ProcessPageEdit' && $edid->template = 'importupdate')) return; $css = wire('config')->urls->ImportUpdateUltimate . 'ass/edit_importupdate.css'; $event->return = str_replace("</head>", "<link rel='stylesheet' type='text/css' href='{$css}'/>\n</head>", $event->return); } protected function filterFieldFields(Hookevent $event) { $page = $event->object; $edid = $this->pages->get($this->input->get->id); if(!($page->process = 'ProcessPageEdit' && $edid->template = 'importupdate')) return; if($edid->iu_template) $tpl = wire('templates')->get((int) $edid->iu_template[0]); else $tpl = null; $fields = []; if($tpl != null) { foreach ($tpl->fields as $f) { $fields[] = $f->id; } $fstring = '[' . implode(',',$fields) . ']'; } else $fstring = '[]'; $js = <<<EOT <script> $(document).ready(function(){ var arr = $fstring; var def = '<option value=""></option>'; if (arr.length) { $('#Inputfield_iu_match option').each(templateFieldOptions); $('#wrap_Inputfield_iu_fieldmap select option').each(templateFieldOptions); $('#_Inputfield_iu_maptab').click(function() { $('#wrap_Inputfield_iu_fieldmap select option').each(templateFieldOptions); }); } else { clearFieldOptions(); } $('#wrap_Inputfield_iu_template .asmListItemRemove').click(clearFieldOptions); function templateFieldOptions() { var val = parseInt(this.value); //console.log(typeof(val)); if (!arr.includes(val) && val>0) { //console.log(val); $(this).prop('selected',false); $(this).prop('disabled',true).remove(); } } function clearFieldOptions() { $('#Inputfield_iu_match').html(def); $('#wrap_Inputfield_iu_fieldmap select').each(function() { $(this).html(def); }); } }); </script> EOT; $event->return = str_replace("</body>", "{$js}</body>", $event->return); }
-
I also want to add a hook which filters a field of fields (FieldtypeSelectExtOption) on Page(template=importupdate)::changed(iu_template) to only display the fields in that specified template in the iu_template field. By default (new page of template=importupdate, if iu_template = null) the field should display no options.
-
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.
-
How to add field of FieldtypeOptions via API???
hellomoto replied to hellomoto's topic in API & Templates
Never mind this works $manager = new SelectableOptionManager(); $options = "0=Import\n1=Update"; $manager->setOptionsString($f, $options, true);- 1 reply
-
- 3
-
- fieldtypeoptions
- api
-
(and 1 more)
Tagged with:
-
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.
- 1 reply
-
- fieldtypeoptions
- api
-
(and 1 more)
Tagged with: