Jump to content

hellomoto

Members
  • Posts

    364
  • Joined

Everything posted by hellomoto

  1. I'm trying this basic example on my localhost: $mail = wireMail(); $numSent = $mail->to($toEmail)->subject($subject)->body($textBody)->send(); Is there a way to tell whether it's working, other than setting the $toEmail to my email address, or is there something I can do to my localhost, since I'm not receiving the email? I'm using FastComet hosting... SSL/TLS settings... to my Gmail... from AMPPS... Any tips?
  2. Okay I need one that allows PHP so that I can display data directly from MySQL. Lost, do you know how can I work yours correctly, considering what I've already attempted?
  3. Lost I tried having it run this file <?php namespace ProcessWire; ?> <script src="https://cdnjs.cloudflare.com/ajax/libs/Dynatable/0.3.1/jquery.dynatable.min.js"></script> <?php $q = wire('database')->query('SELECT * FROM cc_vpv WHERE id = ' . wire('page')->id); echo 'Pageviews= '; print_r($q); ?> unsuccessfully, I know I'm probably just doing something wrong. kixe why isn't yours in the Modules directory? I'll give it a go, thanks guys.
  4. PWaddict I suspected that and installed Languages Support. Prior to doing so it was actually producing a different error earlier up in the module file. Forgot to mention that. But installing it didn't solve the problem for me.
  5. Well I added this now it works not ideal and wasn't needed before but whatever if($template == 'boat_vessel') $p->name = wire('sanitizer')->pageName($r['boat_model']) . '-' . wire('sanitizer')->pageName($r['title']); else $p->name = wire('sanitizer')->pageName($r['title']);
  6. Love this module but I'm having an issue. This import script worked for me outside my module, but now I'm including it inside a module, and getting the following error upon install: Culprit file: <?php namespace ProcessWire; importUsers(__DIR__.'/data/users.csv'); function importUsers($filepath) { $csv = array_map('str_getcsv', file($filepath)); array_walk($csv, function(&$a) use ($csv) { $a = array_combine($csv[0], $a); # set header keys }); array_shift($csv); # remove column header //echo '<pre>'; print_r($csv); echo '</pre>'; foreach($csv as $r) { $u = new User(); $u->of(false); foreach($r as $k=>$v) { $v = trim($v); if($k == 'name') { if($v == '') $u->$k = wire('sanitizer')->pageName($u->email); else $u->name = wire('sanitizer')->pageName($v); continue; } if(wire('fields')->get('name='.$k)) { $fieldtype = wire('fields')->get('name='.$k)->type; if($fieldtype == 'FieldtypeMapMarker') { $u->$k->address = (string)$v; } elseif($fieldtype == 'FieldtypeImage') { $imgs = explode('|', $v); foreach($imgs as $i) { $u->$k = $i; } } elseif(in_array($fieldtype, ['FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeCheckbox', 'FieldtypePassword', 'FieldtypeEmail'])) $u->$k = $v; } if($k == 'roles') { $roles = explode('|', $v); foreach($roles as $role) { $u->addRole($role); } } } if(!$u->hasRole('guest')) $u->addRole('guest'); $u->save(); //echo '<br>'; if($u->password == '') { $u->password = crypt($u->email, $u->id); $u->save(); } } } // email users welcome & verify $mmpid = wire('pages')->get('template.name=mamo_makes')->id; importCSV(__DIR__.'/data/manufacturers.csv', 'mamo_manufacturer', $mmpid); //importCSV(__DIR__.'/data/models.csv', 'mamo_model', 0, $mmpid); //importCSV(__DIR__.'/data/vessels.csv', 'boat_vessel', wire('pages')->get('template.name=boat_index')->id, 0); 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); # set header keys }); array_shift($csv); # remove column header //echo '<pre>'; print_r($csv); echo '</pre>'; foreach($csv as $r) { $p = new Page(); $p->template = $template; if($parent_id !== 0||null) { $p->parent_id = $parent_id; } elseif($parent_id == 0||null) { //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(); $p->of(false); foreach($r as $k=>$v) { $v = trim($v); $fieldtype = wire('fields')->get('name='.$k)->type; if($fieldtype == 'FieldtypeMapMarker') { $p->$k->address = (string)$v; } elseif($fieldtype == 'FieldtypeImage') { $imgs = explode('|', $v); foreach($imgs as $i) { $p->$k = $i; } } else $p->$k = $v; } $p->save(); //echo '<br>'; } } The above portion (users) runs through ok. It's the latter section that produces the error. What is the string being referred to, how can I remedy this? Any ideas as to how I can troubleshoot?? Thanks a ton.
  7. I have a fieldsettab I want to populate with two collapsable fields that are for display not input. One will display data directly from an extra MySQL table (corresponding with PW pages) and the other will list certain PW pages. How do I go about this? I wanted to lay them out using Dynatable, one per each field. Thanks.
  8. I have this installed on PW3 and my supposed pages2pdf link simply loads the page with the get variable specified ={page.id}, not as a PDF. What could be the matter?
  9. Search URL looks like http://localhost/site/en/listings/?make=&hulls=&mobility=&price_min=&price_max=&currency=%24&length_min=&length_max=&sort=-boat_date_list but then next page of results goes http://localhost/site/en/listings/page2
  10. I have this $selector = 'template=boat_vessel, sort=-boat_date_list, limit=3, '; $selected = [ "make" => "", "hulls" => "", "mobility" => "", //"make/model" => "", "year" => "", "price" => "", "length" => "", "location" => "", //"keywords" => "", ]; if($input->get->make) { $selected["make"] = $sanitizer->text($input->get->make); $selector .= "boat_model|boat_manufacturer*=" . $selected["make"]; } if($input->get->hulls) { $p = $pages->get('name=hulls, parent.name=options')->child('name=' . $sanitizer->pageName($input->get->hulls)); if($p->id) { $selector .= "boat_model.mamo_hulls=$p, "; $selected["hulls"] = $p->title; $input->whitelist("hulls", $p->name); } } if($input->get->mobility) { $p = $pages->get('name=mobility, parent.name=options')->child('name=' . $sanitizer->pageName($input->get->mobility)); if($p->id) { $selector .= "boat_model.mamo_mobility=$p, "; $selected["mobility"] = $p->title; $input->whitelist("mobility", $p->name); } } if($input->get->price_min || $input->get->price_max) { $selector .= "boat_price_list>={$input->get->price_min}, boat_price_list<={$input->get->price_max}, "; $selected["price"] = "{$input->get->currency} {$input->get->price_min} - {$input->get->price_max}"; } if($input->get->length_min || $input->get->length_max) { $selector .= "boat_model.mamo_length_ft>={$input->get->length_min}, boat_model.mamo_length_ft<={$input->get->length_max}, "; $selected["length"] = "{$input->get->length_min} - {$input->get->length_max} ft."; } $form = ''; $form .= '<p> <label for="search_make">Manufacturer/Model</label> <input name="make" id="search_make" type="text" value="'.$selected["make"].'"/> </p>'; // manufacturer/model // make $form .= '<p> <label for="search_hulls">Hull Configuration</label> <select name="hulls" id="search_hulls"> <option value=""></option>'; foreach($pages->get('name=hulls, parent.name=options')->children() as $i) { if($selected['hulls'] == $i->title) $select = ' selected'; else $select = ''; $form .= '<option value="'.$i->name.'"'.$select.'>'.$i->title.'</option>'; } $form .= '</select> </p>'; $form .= '<p> <label for="search_mobility">Mobility</label> <select name="mobility" id="search_mobility"> <option value=""></option>'; foreach($pages->get('name=mobility, parent.name=options')->children() as $i) { if($selected['mobility'] == $i->title) $select = ' selected'; else $select = ''; $form .= '<option value="'.$i->name.'"'.$select.'>'.$i->title.'</option>'; } $form .= '</select> </p>'; $form .= '<p> <label>Price</label> <input type="number" name="price_min" id="search_price_min" style="width:80px" placeholder="Minimum" value="'.$input->get->price_min.'"/> <input type="number" name="price_max" id="search_price_max" style="width:80px" placeholder="Maximum" value="'.$input->get->price_max.'"/> <select name="currency" id="search_currency">'; foreach($pages->get('name=currency, parent.name=options')->children() as $i) { $form .= '<option value="'.$i->title.'">'.$i->title.'</option>'; } $form .= '</select> </p>'; $form .= '<p> <label>Length (feet)</label> <input type="number" name="length_min" id="search_length_min" style="width:50px" placeholder="Min." value="'.$input->get->length_min.'"/> <input type="number" name="length_max" id="search_length_max" style="width:50px" placeholder="Max." value="'.$input->get->length_max.'"/> </p>'; $sidebar .= '<form id="boat_search" method="get" action="'.$pages->get("template=listings")->url.'"> <h2>Search Listings</h2>' .$form. '<input type="submit" id="search_submit" value="Search"/> </form>'; // add reset/clear button $sidebar .= '<br>'.implode('<br>', array_filter($selected)); $results = $pages->find($selector); foreach($results as $i) { $content .= '<h3>'.$i->title.'</h3> '; } $content = "<ol>$content</ol>"; $content .= $results->renderPager(array( 'nextItemLabel' => "Next", 'previousItemLabel' => "Prev", 'listMarkup' => "<ul class='MarkupPagerNav'>{out}</ul>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>", 'numPageLinks' => 999, )); This produces accurate search results and paginates effectively without searching; but the search results don't paginate. When the search results overflow a single page, and you go to page 2, it just shows the default second page of all the original results, no search filter. How do I paginate the search results?
  11. Huh. I didn't have that originally and it was behaving the same errant way but now it's working without that so thank you!
  12. I have $results = $pages->find('template=boat_vessel, sort=-boat_date_list, start=0, limit=3, '.$selector); $content .= $results->renderPager(array( 'nextItemLabel' => "Next", 'previousItemLabel' => "Prev", 'listMarkup' => "<ul class='MarkupPagerNav'>{out}</ul>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>", 'numPageLinks' => 999, )); But I go to /page2 and the same 1st page of results is displayed, and the pagination itself doesn't change, there's no previous link, the page 1 link is still classified as current.
  13. This is true, and is what I have, but it's not working in another custom import script I'm working on currently: 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); # set header keys }); 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) { //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(); $p->of(false); foreach($r as $k=>$v) { $v = trim($v); $fieldtype = wire('fields')->get('name='.$k)->type; if($fieldtype = 'FieldtypeImage') { $imgs = explode('|', $v); foreach($imgs as $i) { $p->$k = $i; } } elseif($fieldtype = 'FieldtypeMapMarker') { $p->set($k->address, $v); // $p->$k->address = $v; } else $p->$k = $v; } $p->save(); //echo '<br>'; } } I have tried the way you mention here that's commented out in my code as well, to no avail. Edit: It should be $p->$k->set('address', $v);
  14. Also module isn't working for me in 3.0.42. Upload shows no file (just the field is active but file is a no-show) and if I try pasting CSV in both cases I can go to the next step but no file headers are present to match.
  15. I have an importer function that goes like this so far 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); # set header keys }); 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) { //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(); var_dump($r); foreach($r as $k=>$v) { $fieldtype = wire('fields')->get('name='.$k)->type; echo $fieldtype.' '; if($fieldtype->name == 'FieldtypeImage') { $imgs = explode('|', $v); foreach($imgs as $i) { $p->$k = $i; } } elseif($fieldtype->name == 'FieldtypeMapMarker') { echo 'mapmarker'; $p->set($k->address, $v); } else $p->$k = $v; } $p->save(); echo '<br><br>'; } } It reads the field as being a MapMarker but does not input the address data?
  16. I added support for FieldtypeMapMarker (->location) if you want to incorporate into the module master, here
  17. I'm trying to alter some code I used to do something similar (fields for selected template) on another project (here) and so far just this simple direct snippet is not doing anything: public function init() { $this->pages->addHookAfter('render', $this, 'filterModels'); } public function filterModels($event) { $page = $event->arguments('page'); if($page->template != 'boat_vessel') return; $this->message("models filter"); } The module is active... Why no results?
  18. Actually it does, but you have to save the page to get the childpages field options. How can I auto-save the parentpage field on selection change and immediately subsequently auto-refresh the childpage field?
  19. I have a manufacturers page select field and a dependent models one with pages of template `model` which are allowed children of pages with template `manufacturer`. So I have this as the findPagesCode for the models page options field: return $page->manufacturer->children(); However this requires the page be saved in order to display options. This is not ideal. I have a singular autoload module with the following: public function init() { $this->pages->addHookAfter('render', $this, 'filterModels'); } public function filterModels($event) { $page = $event->arguments('page'); if($page->template != 'boat_vessel') return; $this->message("models filter"); } It's doing nothing. I was thinking I could work out something with this example but I would need the above test to be working first anyway... $this->pages->addHookAfter('changed', function(HookEvent $event) { $page = $event->object; $change = $event->arguments(0); if($page->template == 'boat_vessel' && $change == 'manufacturer') { // execute some code } }); But what? How do I refresh the models field? Is there a way to do this in the field settings? I would think in the custom PHP textarea that `return $page->manufacturer->children();` would work but it doesn't.
  20. Sometimes my file uploads get stuck on 100% and do not complete, even if I try with a zipped version. So then I try adding the file to the page files directory and inserting a new record in the field's table. Sometimes this works, sometimes not. When it doesn't, what to do? Is there a way to add the db record via API that'll register in the page? The existence of the record itself should present, I don't understand.
  21. Apparently it comes from line 6 in this file (vessels.csv) <?php namespace ProcessWire; $mmpid = wire('pages')->get('template.name=mamo_makes')->id; importCSV(__DIR__.'/manufacturers.csv', 'mamo_manufacturer', $mmpid); importCSV(__DIR__.'/models.csv', 'mamo_model', 0, $mmpid); importCSV(__DIR__.'/vessels.csv', 'boat_vessel', wire('pages')->get('template.name=boat_index')->id, 0); 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) { //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; // if MapMarker field set to ADDRESS subfield $p->save(); //echo '<br>'; } } That's odd because this isn't even supposed to be deleting anything, it's imports. How does this happen? This same code was working before, imported the boats just fine, I would just have to refresh the page once to clear that same error, but it would clear itself.
×
×
  • Create New...