Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/17/2020 in all areas

  1. This suggests that the query string does not receive the search string but an object of type WireInputData instead. WireInputData is the class behind the WireInput properties $input->get, $input->post, and so on. $q = $sanitizer->selectorValue($input->get); $input->whitelist('q', $q); Here you put the $input->get object of type WireInputData into a sanitizer method. The method only accepts strings and arrays. Since you gave it neither, it makes a string out of it. I guess this turns the WireInputData object into the string "WireInputData". Not sure what the right fix is. What is “q” supposed to be? It looks more like the query string you want is something like “?larghezze=123&lunghezze=456”. So you should put each of those into a separate whitelist item, eg. $input->whitelist('larghezze', $input->get->selectorValue('larghezze')). ProcessWire’s pagination will automatically put everything from $input->whitelist in the url query string. if($input->whitelist->lunghezze) echo $sanitizer->entities($input->whitelist->lunghezze); if($input->get->lunghezze) echo ($input->get->lunghezze); //delete this! Here you output lunghezze twice, only the first line doesn’t work, because you never put anything into $input->whitelist->lunghezze. Also, the whitelist is stored on the server and you’re expected to only fill it with things you already sanitized, so there is no need to sanitize it again at that point. In the second line you output untrusted unsanitized input straight from the GET request! You should delete that line and the others like it. They’re unnecessary anyway, because you already output the whitelisted stuff above ? Change it to this: echo $input->whitelist->lunghezze; That should be all you need. Then, in search_alimentare.php, add the line I highlighted: if ($input->get->lunghezze) { $lunghezza = $sanitizer->selectorValue($input->get->lunghezze); $input->whitelist->lunghezze = $lunghezza; //add this line for each get variable $tolleranza = ($percentuale / 100) * $lunghezza; $val_up = $lunghezza + $tolleranza; $val_down = $lunghezza - $tolleranza; $selector .= "variante_prodotto.lunghezza>=$val_down, "; $selector .= "variante_prodotto.lunghezza<=$val_up, "; } Sorry I’m being so incoherent ?
    4 points
  2. For a brief moment I was contemplating parsing HTML with regex but then StackOverflow taught me this: https://stackoverflow.com/a/1732454/1036672 My sides are now hurting ?
    4 points
  3. Totally worked thanks @adrian, I guess I just don't expect things to go this bizarrely wrong. After updating I found my template with the same name as the repeater. I added the template again and now everything is fine...
    3 points
  4. @Jan Romero Just here to say thanks for your detailed answer, is such amazing how much this community surprises me even after years. I'm going to test your suggestion tomorrow at office time, and be back here to mark (hopefully) solved this thread. Thanks again, really really appreciated your effort.
    2 points
  5. Hi @Markus (Blue Tomato), thank you for the update. I tested the new version and the generation and storage of the blurhashs works fine! On a side node, I find it still strange that the custom SQL did not (always) work. After upgrading my issue with "undefinded offset" was still present. I checked the used PHP Blurhash library and your code and I adjusted lines 108 and 109 and replaced $height and $width with $calcHeight and $calcWidth. This solves the issue (no more notices), but I don't know if it has any drawbacks..
    2 points
  6. Hello, I would like to present you a new module which aim to facilitate the productivity of your editors/publishers when working on ProcessWire. The idea begun when my co-worker told me that when typing in ProcessWire CkEditor field he was feeling "loosing motivation" when writing big wall of text and/or inspiration. So he opened his web-browser and show me a site looking to Wordpress - feel free to put your preferred emoji here - then he opened Gutenberg... typed some text and moving some "blocks". I understood immediately why he got this feeling with CkEditor. If you or your client feel like this guy, then you will love this module ! What is currently supported ? Features Auto-save Medias upload support HannaCode support Blocks Implemented Heading Image Paragraph Embed Quote Code Link Table (beta) Block Delimiter Raw HTML Note (custom block markup) Feature Request Frontend Edition And there you go for the preview - sorry I am to lazy and bad at typing text so I had a copy/pasta moment : Module featured in the ProcessWire Weekly #317 - Thanks @teppo
    1 point
  7. Hi MoritzLost, That is just for the interface (menus, formulas...) the body field contains each post in any language. I have a default language and an URL segment to get the chosen language. The translators complete the files once only per language.
    1 point
  8. Hello, I wanted to export my site profile back up from the live server to my local. I have always been happy with using Site Exporter but, this time, when I took my backup file from server, and tried to install in my local machine, I got this error below Profile Not Found I am sure I have placed the exported files to the directories and made permissions accessible. So I installed the module duplicator and installed it. As per the doc says when I try to access it from Setup -> there is no duplicator showing. All screenshots are attached I made it possible to install it on local machine by simply changing my folder site-june17bkp to site and installation went smooth. But not sure why the profile not found and/or duplicator not showing in the list. thanks in advance
    1 point
  9. thanks for the quick reply. its done now.. thanks again
    1 point
  10. @JeevanisM I don't know what's going on with the Site Profile Exporter, but for Duplicator, you need to install the ProcessDuplicator module (Modules > Install > ProcessDuplicator).
    1 point
  11. That’s a classic, but I’ve been scraping some stuff lately, and I’m not ashamed to say it looks like this and works fine: Regex playlistRegex = new Regex(@"playlist = (\[.*?\]);", RegexOptions.Singleline); Regex titelRegex = new Regex("player-archive-date.*?>(.*?)</div>.*?<span>(.*?)</span>", RegexOptions.Singleline); Regex mp3Regex = new Regex(@"stream_url\s*?=\s*?'(.*?\.mp3)';"); Regex datumRegex = new Regex("datum=([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9])"); //… var i = line.IndexOf("/player/xxx/?xxx=xxx"); if (i == -1) continue; c++; line = line.Substring(i); line = line.Substring(0, line.IndexOf("\");'")); line = line.Replace("&", "&"); var datum = datumRegex.Match(line).Groups[1].Value; *cough* Of course, I can make solid assumptions about my input here. The limited problem of stackoverflow’s OP seems somewhat suitable for regex, too, although I’m unsure what they’re trying to accomplish. Find all non-self-closing opening tags?
    1 point
  12. @Crowdland Technology Many thanks. I have fixed it in the Github Repo.
    1 point
  13. There's no need at all to understand the PW architecture or database structure and relations - or even to think about these things. Stick to using PW selectors (https://processwire.com/docs/selectors/) and all the hard work is done for you. Selectors are one of the really great features of PW! (Note that if you later decide to use RockFinder for the extra speed, it also understands the PW database structure so that you don't have to.)
    1 point
  14. Yeah, that version is 3 years old ?
    1 point
  15. @Tyssen I've run into that error a couple of times, I think it's specific to the Selectable Option field. I think it's related to how Twig tries different ways to get a property value from an object. ProcessWire uses magic __get methods all over the place, which are checked quite late by Twig. So Twig first tries to call hasValue on the object, which exists but requires additional arguments, so it breaks ... A workaround is using more explicit properties, either of those should work: {{ matrixBlock.fieldName.getValue }} {{ matrixBlock.fieldName.first.value }}
    1 point
  16. Works fine with FormData object and without set Content-Type Header... var body = new FormData(); body.append("name", "Bob"); body.append("age", 27); fetch("http://127.0.0.1/fetch.php", { method: "post", body: body }).then(function(response) { console.log(response); return response.JSON(); }).then(function(result) { console.log(result); }); <?php $res = $_POST["name"]; print_r($res); die();
    1 point
  17. Rather than edit the DB for an existing field, you could make a simple fieldtype module that extends FieldtypeTextarea: <?php class FieldtypeLongTextarea extends FieldtypeTextarea { /** * Module information */ public static function getModuleInfo() { return array( 'title' => 'Long Textarea', 'version' => 1, 'summary' => 'Field that stores multiple lines of text in a MySQL LONGTEXT column type.', ); } /** * Get database schema used by the Field * * @param Field $field * @return array * */ public function getDatabaseSchema(Field $field) { $schema = parent::getDatabaseSchema($field); $schema['data'] = 'longtext NOT NULL'; $schema['keys']['data'] = 'FULLTEXT KEY data (data)'; return $schema; } }
    1 point
  18. Hi Stephen, Welcome to the forums and good question. Here's one way you could approach it, assuming all those posts were under the same page (like /blog/). I'm somewhat limited on time right now, so this is written in the browser and not tested, but I can follow up with more detail later if you'd like. <?php $blog = $pages->get("/blog/"); $startYear = date("Y"); // this year $endYear = 2009; // or whenever you want it to end $now = time(); for($year = $startYear; $year >= $endYear; $year--) { for($month = 12; $month > 0; $month--) { $startTime = strtotime("$year-$month-01"); // 2011-12-01 example if($startTime > $now) continue; // don't bother with future dates if($month == 12) $endTime = strtotime(($year+1) . "-01-01"); else $endTime = strtotime("$year-" . ($month+1) . "-01"); $entries = $blog->children("created>=$starttime, created<$endTime"); // or substitute your own date field $date = date("m-Y"); echo "<li><a href='./$date'>$date - " . count($entries) . "</a></li>"; // output the month and count } } Then you'd use the same template to list the entries when a $input->urlSegment1 has a date specified in it. Basically you'd cycle through the $entries found above and link to them. This is rough and just approximate. I'll be glad to follow up with more detail... but wife is telling me to get off the computer.
    1 point
×
×
  • Create New...