Jump to content

Ivan Gretsky

Members
  • Posts

    1,510
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by Ivan Gretsky

  1. Ok. 1. We need to generate a unique token for a user and store it. The simple way to do that is to add a field to user page (login_token in the example). To make process easier we make a method for that via hook: // site/init.php $wire->addHook("User()::getToken", function(HookEvent $event) { $page = $event->object; if (empty($page->login_token)) { $page->of(false); $page->login_token = generateToken(12); $page->save(); $page->of(true); } return $event->return = $page->login_token; }); The genereateToken() function is yours to implement as you wish. 2. Now we can generate a link: $link = $page->httpUrl . "?user=". $user->id . "&token=". $user->getToken(); 3. Finally we need to handle those parameters and make user autologin: // site/templates/_init.php if ($userToLoginId = $sanitizer->int($input->get->user)) { $url = $page->url; $userToLogin = $users->get($userToLoginId); $tokenToLoginWith = $sanitizer->text($input->get->token); if ($userToLogin->id && $tokenToLoginWith && strcmp($userToLogin->login_token, $tokenToLoginWith) == 0) { $loggedInUser = $session->forceLogin($userToLogin); if ($loggedInUser) { $user = $loggedInUser; }; $session->redirect($url); } } We can then nullify user token if we want it to be only a one-time ticket. I rewrote whole lot of stuff, so might not work straight away, but surely you can fix it @szabesz)) Hope I am not missing something essential.
  2. Hey, @szabesz! It was done. Actually It was pretty easy (at least the way we implemented it without much security overthinking). Would be happy to share code if needed. But it is essentually what @LostKobrakai wrote.
  3. This topic made me check the progress on Atom IDE project. The 1.21 version of atom is finally out of beta, so now one can install it without switching to beta channel. Atom IDE uses the same Felix Becker's language server, and has language contexts figured out, as far as I know. While at it upgraded my Windows Atom to x64 version (startup appeared to be a little faster, but maybe I'm just dreaming). Jump to class definition works. Auto-completion works, Outline view is present. Somehow I consider Atom to be more open source and open in general than VS Code. So will try stick to it for now. VS Code starts up a bit faster, but they have near feature parity now. Good competition is good!
  4. It is html, css and js in php files. IntelliSense (at least out of the box) just does not recognize that it is html context embedded in php PW template, so no autocompletion and stuff. Felix Becker (the creator of php language server, used in VS Code as the base for php IntelliSense) writes about it in the mentioned issue. I did not find a workaround. Edit: Actually the main problem is the other way around. PHP includes in html templates/views.
  5. This issue is what primarily stops me from using VS Code for php development (and that means "at all").
  6. @ryan, just tested the new page export/import module in zip-mode. I was able to move some rather basic pages with images from one installation to another. Felt like launching a spaceship. And it worked! Yahoo! Congratulations! I did not get into much testing, but spotted a bug. When using "Pages that I select" and "Pages having parents" options? I could not actually select pages. The select button appears when hoverung a page and disappears instantly not allowing to make a selection. So I had to cope with selector option. Tested on 2 computers with the same result.
  7. Good day, @horst! Was messing with an old site of mine. I did not even remember I used pim2 on this one. And getting to use this powerful tool once again was a pleasure. Thank you for your work! I had to make a overblurred version of an image for a background. So I used smooth(255) about a 10 times in a row. That did the trick, but the code looks kind of ugly. Am I missing some shortcut way to do it in a more beautiful manner?
  8. I am facing the same problem. Made a github issue to get more attention to it.
  9. Thank you Ryan! Both modules look awesome! And I see use cases for both of them on sites I am working on right now. It is especially nice to see these developed in response to a community feedback made through a PW weekly poll. And this is the first reason I hope both fill be released in the core. The second is that that FieldsetGroup is such a natural and kind of even expected extension of the regular fieldset it must be valuable to many. I got my ProFields subscription anyways, but still...
  10. The answer to the original question seems to be: // use this $config->httpHosts = array(); // instead of this $config->httpHosts = array(''); I guess the 2nd line creates an array with an empty item, not an empty array. But I still have a problem with empty httpHosts config on https sites. They just do not want to work without $config->httpHosts set explicitly.
  11. This stuff is amazing! The built-in help videos for ERPNext are auto-generated and are always in sync with the evolving interface. Just wanted to share.
      • 1
      • Like
  12. Hey, @flydev! I am sure those that are not beta testers will have most questions, so better ask us, eagerly waiting for the release, after it happens) Glad you are back here, by the way!
  13. Good day @adrian! Tracy debugger is one of the tools I can't live without no more Thanks for supporting it! I got an unexpected behavior I can't explain. Tracy bar foes not appear on form sent (there is actually quite a lot happening processing that form). I does appear on all other pages of the site as expected though. That can cause such behavior?
  14. Just read your comment here and found out AOS now has some profound documentation. You're a monster, @tpr! The wiki is awesome! I saw it and said to myself: "Ha, but he probably does not have changelog!" But I was wrong (and astonished)! I think the main PW repo could benefit from a CHANGELOG.md like this. Especially that there are enough of nice changes to be mentioned almost every week. Sorry for offtop))
  15. Admin on steroids adds that functionality (among many others). Just for the record.
  16. Great, @mel47! But I was not actually advising to add an extra field to the template. I thought it would be enough just to write $page->sizeColumn = 2; before the render call. It would add a temporary property to the current $page object, which will be passed to field template (but will not write this field to database).
  17. When you create a new product page a reference to some tags get automatically added to the product page, right? Is it your site or you are working with some clients you did not make? What tags are added? It might be that it is done with some hooks. If so, you can check the site/modules folder for some suspicious modules and read through site/ready.php and/or site/init.php - they might be there .
  18. Hey, @webhoes! I did not dive too deep into your code, but: I think you use $inputs instead of $input. I don't see the code for the form which has to include the select and therefore do not see the way that r_selector will ever get into the $input object. You need to sent the form to get the input parameters.
  19. There are a couple of topics kind of about this question with working solutions: https://processwire.com/talk/topic/9675-page-field-bidirectional/ https://processwire.com/talk/topic/14689-connect-page-fields/ But there are other ways. Put page reference field on vehicle-template template and add synonyms from there. Create a separate category for vehicle groups and reference category pages from both vehicle-template and vehicle_synonym-template (do you really need 2 of them?) Add a RuntimeMarkup with some easy-to-write php finding and showing the pages you want to back-reference.
  20. Hey, @mel47! Here is the code for the method. Seems like the 3rd parameter is to override default field value, not to provide additional variables to the template: @param mixed|null $value Optionally specify value to render, otherwise it will be pulled from this $page. Did not try this, but you probably can do this to have additional variable in the field template context: // main template $page->$sizeColumn = 2; $content .= $thanks_page->render('images', '/images_column'); // images_column.php foreach($value as $image) { echo " <article class='column is-{$page->sizeColumn}'> .... }
  21. Hello, @Slav! Is it an admin or public frontend form? If it is accessible to the public, please provide the link - it would help a lot. If not, open browser devtools console and look for js errors there. I am asking because the screenshot does not look like stock PW admin theme.
  22. I can guess that 403 errors are thrown by the server, not PW. Here are the conditions for that in stock .htaccess file. Maybe you named your dev site folder without the "site-" prefix?
  23. There is a nice tool for Joomla! which seems to be free for csv export. It will probably not help you to deal with the site structure though. But I am sure you will be able to handle this manually. 175 pages is not that many after all)
  24. Might not be the best thread for this, but as you mentioned tracy... Wanted to let @adrian know, we, his PW fans truly appreciate what he is doing promoting our beloved system.
  25. Yep, that sounds easy. Just thought I would try out something ready-made from my favourite module-builder)
×
×
  • Create New...