-
Posts
370 -
Joined
Everything posted by hellomoto
-
I have this $pdf = $modules->get('Pages2Pdf')->render(array( 'title' => 'PDF', 'markup' => '<a href=\'{url}\' target=\'_blank\'>{title}</a>', 'page_id' => '', )); $content .= <<<EOT <script type="text/javascript"> $("h1").append(" <small>[$pdf]</small>");</script> </script> EOT; which outputs to /?pdf={pid} but clicking the link just opens the current page in a new tab, no PDF.
-
In PW 3.0.42 when editing a user this error appears up top:
-
When I click on any of the actions in the list I get this: Anyone know why
-
Cannot read/open CSV file from field in page under admin
hellomoto replied to hellomoto's topic in Module/Plugin Development
I tried using that with ../'s in the value to grab from the module's directory to no avail. Here is the module in progress: The file in question is import/csv.class.php. I appreciate any and all feedback regarding the makeup of this module. -
Cannot read/open CSV file from field in page under admin
hellomoto replied to hellomoto's topic in Module/Plugin Development
I have this happening in the template file: if(file_exists($filepath)) echo $filepath; echo "<a href='$filepath'>csv</a>"; $file = fopen($filepath, 'r'); print_r(fgetcsv($file, 0, ',', '"')); fclose($file); where $filepath = $this->source->url (in a class method). So it's the page's attached CSV file's URL. The link works and downloads the file, which supposedly doesn't exist, according to the preceding line. Why?? -
I am working on a module that runs/previews (for pub/unpub) imports on importer page view. The template has to be in site/templates, so far as I know, so one is created there on install which includes a file to run from within the module, but then when it's run and tries to read the importer csv file it cannot, since it's in the admin, I guess... Is it possible to set the template page to a file in the module directory? Will that work?
-
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?
-
Display custom content in otherwise empty FieldsetTab?
hellomoto replied to hellomoto's topic in General Support
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? -
Display custom content in otherwise empty FieldsetTab?
hellomoto replied to hellomoto's topic in General Support
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. -
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.
- 100 replies
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
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']);
- 100 replies
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
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.
- 100 replies
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
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.
-
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?
-
Search URL looks like http://localhost/site/en/listings/?make=&hulls=&mobility=&price_min=&price_max=¤cy=%24&length_min=&length_max=&sort=-boat_date_list but then next page of results goes http://localhost/site/en/listings/page2
-
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?
-
renderPager showing 1st results on every page# and pagination
hellomoto replied to hellomoto's topic in General Support
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! -
renderPager showing 1st results on every page# and pagination
hellomoto replied to hellomoto's topic in General Support
Yes indeed -
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.
-
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);
-
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.
-
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?
-
I added support for FieldtypeMapMarker (->location) if you want to incorporate into the module master, here