Jump to content

Jan Romero

Members
  • Posts

    680
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Jan Romero

  1. Tbh for one-off imports I usually transform the csv (or whatever it is) into PHP or SQL using regex replace in Notepad++ and then just run that. 1500 rows should be nothing, unless they’re absurdly long. edit: nvm, I missed the 1.000.000 figure, but still, writing to the database directly should be an efficient option. In MySQL might want to use LOAD DATA INFILE, but you’ll have to adjust the input data first.
  2. Are you using multiple languages by any chance? There was a thread with a similar problem. Unfortunately not much came of it. I never looked into the underlying cause after I got it working again…
  3. This is because non-superusers aren’t allowed to add children under /processwire/setup/languages. First, because /processwire/setup/languages is of template admin, you would need to open the template settings for admin and check the box “add children” in the access tab. Then you also need to give them permission to create pages of template language, so in the language template, enable access control and check “edit pages” and “create pages”. This isn’t a very nice solution, because you have to change access for all admin pages. I suppose it would be neat if a “lang-add” permission came with the language support module. Alternatively, you can probably write a hook to add a button somewhere that creates a language and bypasses those permission checks.
  4. The ^= operator should do it: $matches = $pages->find("limit=0, title ^= '$letter'");
  5. I’d use FieldtypeTable: https://processwire.com/store/pro-fields/table/ It’s not free, though.
  6. I’ve never used that module, but as far as I understand you’re supposed to just check the required box in the field settings. If you reuse the fields in other templates where they are not required, you can check the box in the template context field settings. Looking at this line it might only work for text fields? Not sure what that’s about, but you can always hook LoginRegister::buildRegisterForm and modify the result yourself.
  7. Hi I’m posting drunk again, and I just want to say, this module is awesome! Thanks a bunch, teppo, you’re the man. I feel much better with this after giving a friend edit permissions on my site ? But also, one thing, does anyone else feel that the diff should always be old to new? Right now when you open the history and click the most recent compare button, it’s the other way around. Wikipedia gives you one radio button for each version to compare and simply doesn’t let you select old to new. It’s kind of awkward and over-engineered, but I think the spirit of not going backwards in time is intuitive.
  8. sort=-date will sort by date from latest to oldest ?
  9. Welcome to PW! You mean this demo site? There is a link to the code on github: https://github.com/ryancramerdesign/skyscrapers2 It’s a couple of years old though. A lot has happened in ProcessWire since then ? Be sure to read through the blog, that’s where all the gems are.
  10. 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 ?
  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?
  12. Guess you’ll want to hook FormBuilderProcessor::savePageDone if FormBuilder hasn’t changed since the beta versions. #24 is the latest one I could dig up, personally. That’s from 2014. But like I said, these are questions for the FormBuilder forum.
  13. @Dean After the creation of the user. So for example after $registerUser->save(); $registerUser->of(true);
  14. Sure, you can just put this in there: $m = new WireMail(); $m->to($email); $m->from('noreply@yoursite.cz'); $m->subject("Welcome to my cool website, {$user}!"); $m->body("Holá {$user}, welcome to the site."); $m->send(); Depending on the volume of sign ups you expect, you may want to do something more robust, though.
  15. Might be something to do with FormBuilder then. Is that how FormBuilder generates temporary page names or something? Unfortunately I don’t have FormBuilder, but if your license is still fresh you might want to run this by the FormBuilder support forum. The way your code looks, I suppose you don’t want FormBuilder to handle submitted requests at all, since you’re rolling everything yourself. So perhaps you want to use its “Submit to another URL” option.
  16. Mh, I dunno, looks fine to me, although you could eliminate one of the two save() calls and it’s unclear where the variables after the call to createUser() come from. I’m going to guess the problem is somewhere else. Have you confirmed that the POST data arrives and makes it through sanitation as expected? Are you using any other modules that may be involved in this process? Do the misbehaving fields have any validation or default value settings? Is “0.78273300-1590946171” the user’s title or its name or both? I see you’re not setting the title in your latest snippet, but if it’s just the title that shouldn’t interfere with the login.
  17. Are you not using the LoginRegister module anymore? I believe it has a feature that allows users to login with their email address. If you’re using the module, but you’re just doing your own registration, you might need to give the new user one or more roles for them to work with LoginRegister. In the module readme it says users are created with the “login-register” role. It’s curious that the page title is not what you explicitly set in the code you’ve shown. No idea why that happens. Since you’re creating a user, you should probably use $np = new User() instead of $np = new Page(), but I’m not sure if it makes any difference at that point.
  18. It’s both! A user is a special kind of page. If you look at ProcessWire’s source code, you will see that the User class extends the Page class. At first it’s a little confusing, but it’s pretty cool because you roughly always deal with the same (or quite similar) things in PW. For example, you can find users using selectors just like finding pages of content. You can also modify and save them the same way, as you did in your hook. And if you want to add a field to your user (maybe a profile picture) you know just what to do: create a field and add it to the template, just like any other content.
  19. Uh, I’ve never used LoginRegister, but some pointers: Not sure if you can use the hook arguments that way. I always use $event->arguments(0) (it’s a method). You should probably hook createUserReady instead. This fires immediately before the user is saved, so you don’t need to do it. You aren’t setting the user’s template to 57.
  20. I think this may be the problem. 58 seems to be the ID of your template, but the config setting must be supplied with the ID of the page. In your example from the opening post, that page is “Members”, so you want to change Members’ template to owners (58) and put Members’ ID into $config->usersPageIDs. It’s probably a four digit number rather than a double digit template ID.
  21. Hm, have you set the corresponding “allowed templates for children” and “allowed templates for parents” options in the templates’ family tabs?
  22. I would probably prefer to put my users under the Members page directly. That way you would still end up with your suggested page tree, but those pages would actually be the users and there would be no need to maintain a relationship between users and their pages. Have a look at this blog post for a tutorial: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users
  23. WTF this actually works! I’ve also had this problem a couple of times since upgrading to ProcessWire 3. Somehow all kinds of Javascript stop working. I can see that mouseenter and mouseleave events are attached to the menu buttons, for example, but the events don’t seem to fire. There is nothing in the Firefox console to indicate an error. Pretty annoying stuff. I’ve just had a client report this to me as well and the best I could tell them was to try logging in through a private tab… As @Roberts R says, this should really be looked into. It’s a frustrating experience even for me just working on my own stuff, but clients are rendered completely helpless when it happens.
  24. I don’t see why it should, but fwiw I’m not running it. I’m a little lost here. Any more info on your setup and how you’re testing exactly? Perhaps someone else can chime in, I’m sure there are other ways of doing something like this. Likely more elegant ones too ? A less elegant way that comes to mind would be to do the check at the top of your 404 template, then change the status header to 200 render the page you want instead…
×
×
  • Create New...