Jump to content

bernhard

Members
  • Posts

    5,714
  • Joined

  • Last visited

  • Days Won

    270

Everything posted by bernhard

  1. Snippet to easily add Inputfields with intellisense support ? "Get PW Inputfield": { "prefix": "field", "body": [ "/** @var Inputfield$1 \\$${2:f} */", "\\$${2:f} = \\$this->modules->get('Inputfield$1');" ], "description": "Get PW Inputfiel" }, PS: Turns out that the chaining syntax as shown in the demo does not properly work with intellisense, so I'll use single line method calls in the future ?
  2. Here a short tutorial of how to use file fields in ProcessModules because I needed that today. File fields are somewhat special as they are usually connected to an existing page with an existing ID and folder in /site/assets/files. But it is also possible to use the Inputfield alone to provide a GUI for uploading files (just like it is done in ProcessDatabaseBackups or the Modules GUI): /** * Import CSV file * * @return string */ public function executeImportcsv() { $form = $this->modules->get('InputfieldForm'); /** @var InputfieldForm $form */ $tmpDir = $this->files->tempDir('upload_csv'); // get path of temp directory $f = $this->modules->get('InputfieldFile'); $f->extensions = 'csv'; $f->maxFiles = 1; $f->descriptionRows = 0; $f->attr('id+name', 'upload_csv'); $f->label = 'Upload CSV'; $f->icon = 'download'; $f->destinationPath = $tmpDir; // here we set a custom destination path $form->add($f); $form->add([ 'type' => 'submit', 'name' => 'submit', 'icon' => 'download', 'value' => 'Import', ]); if($this->input->post->submit) { $form->processInput($this->input->post); // if there where any errors we exit early and render the form // we also exit here if no files where uploaded if($form->getErrors() OR !count($f->value)) return $form->render(); // loop all uploaded files // here we have only one file maximum, but still it is an array foreach($f->value as $pagefile) { // the regular pagefile's filename is incorrect because it links to // /site/assets/files and not the tempDir, so we get the correct path $file = $tmpDir . $pagefile->basename; // ####################################### // now do whatever you want with that file // ####################################### } // redirect to somewhere $this->session->redirect("/admin/somewhere/"); } // form was not submitted, so render it return $form->render(); } The result: When you upload an invalid file it will show a warning:
  3. @AndZyk not sure, but that seems to be the same thing that I posted earlier just not for vscode but for visual studio?
  4. Don't know if that restriction makes sense at all. Could you just include('../yourfile.php'); in the prependTemplateFile?
  5. Seems like Microsoft was watching this thread closely ? Let's continue the discussion regarding VSCode in the dedicated VSCode Thread!
  6. VSCode introduces Remote Development in the new Insiders Release! https://code.visualstudio.com/docs/remote/remote-overview Seems like they were watching our thread here closely ?
  7. Thx for sharing! I wonder why you don't use dev as default and only list the live server name as one case statement. Then you would not need to list all dev domains and could even create new ones without changing the config ?
  8. Yeah, I also had a good experience with it on the short tests I did so far. For me it would just be too much hassle to change php/db versions, create ssl certs, create vhosts or have a mailcatcher without such a tool...
  9. Have you tried devilbox? The other two quotes are getting too much offtopic, even though I'm enjoying the discussion ?
  10. For sure Adrian will be faster than anybody else, but just see how he does those things with eg the vscode file editor links setting and do the same. This will never take you 2-3 days, I'm sure. And I guess you'll learn something new (otherwise you would not think that such a modification would take so long). But I don't mean that as an offense. I just think that everybody of us (me included) should try to contribute as much as possible and not just request things ?
  11. Laragon? On Linux? Or what are you talking about? ? Don't work often with it. Only when I'm at clients and then I mostly do just taking notes etc... I just try to stick with one - at least as long as I'm more experienced with linux ? Thank you for the discussion ?
  12. Yeah, I'm also running Ubuntu (18.04) on my X1 Carbon. It looks great, it works great... And it would be the exact same OS as most of my servers ? And free, which is also great ?
  13. Sounds like an easy and valuable PR ?
  14. Boom! Finally I've got Intelephense working as expected ? Before: After: Turns out that it is already available as setting in settings.json:
  15. Agree after doing a lot of testing during the last days... Wow, thx for that list @gmclelland! c9 looks promising, but I want to stay with vscode. Something like c9+vscode would be awesome. I decided to stay with a local dev environment for now. Thx @FrancisChung for the popOS link. I've watched some youtube reviews. It looks nice indeed.
  16. I've worked much more in the admin those days, but I also like markup regions a lot! The only two "fancy" things I can think of are: 1) Remove the "boxed layout" (uk-container class) for some regions (eg when you have a boxed website in general but want the frontpage to be full width): <region id="mainsection" class="-uk-container">...</region> The nice thing is that this works completely without any if/else blabla as one would usually do it ? 2) Region at the end of the body: <body> ... <region id="bodyend"></region> </body> Then I can inject code from views where I need additional javascripts or the like, eg sliders or here using foxycart: This example also shows how easy (and clean) it is to add FormBuilder to this "view" (just using pw-append on the head).
  17. Good points! Htacces changes are very rare anyhow, so that would be totally fine. I'll think of that option in the future ?
  18. Hi Horst, I'm late on that one, thx for all your work! ? $image = $page->images->first()->size(300, 300); ?> <picture> <?php if($image->hasWebp) { ?> <source srcset="<?=$image->srcWebp?>" type="image/webp" /> <?php } ?> <source srcset="<?=$image->src?>" type="image/jpeg" /> <img src="<?=$image->url?>" alt="Alt Text!" /> </picture> What about something like this to ? $image = $page->images->first()->size(300, 300); echo $image->hasWebp( "<source srcset='{srcWebp}' type='image/webp'/>", "<source srcset='{src}' type='image/jpeg'/><img src='{url}' alt='{description}'/>" ); Such a method could even be extended with custom templates set via $config->webp or the like and could also get a third argument for options. Then the example above could be: echo $page->images->first()->size(300, 300)->hasWebp(); ...and produce the exact same output as your example. Maybe $img->webp(...) would be a better name for such a method than $img->hasWebp(...)
  19. Because the projects I did lately didn't need forms or needed some more complex ones and I used FormBuilder for that. I find nette forms a little complicated to understand and modify. The PW forms api is a lot cleaner (at least to me, being familiar with PW). Other solutions are: Custom HTML/PHP Forms Forms API FormBuilder (commercial module)
  20. Hey everybody, thx for all your great input! ? After trying lots of different things, watching lots of youtube videos and reading lots of tutorials and docs I'm one step further (or not ? )... I've tried devilbox, I've installed ubuntu on my laptop, I've tried nomachine, I have -not- tried https://remmina.org yet (got that hint yesterday from @Christophe ), I've forgotten what else I've tried ? Somehow I'm going in circles... Everything has its pro's and con's... Ubuntu (18.04) Really nice experience! VSCode works perfectly and development would be on a linux machine. I'd also learn more about linux, which would always be a good idea. The problem is that I'd then need to maintain 6 environments instead of 3 (3xWin10, 3xUbuntu). Maybe I could do a mix. A friend mentioned https://www.ansible.com/ - but I guess that makes things just even more complicated. I guess some manual work will always be necessary to some extent. Another problem using Ubuntu is the server setup... how to handle different vhosts, different projects, different php versions? Devilbox Devilbox should solve that problem. It should also work on all platforms that support docker. But it is quite complicated to setup (compared to laragon, that will even run on a USB drive) and it's quite slow on windows. Apart from that it looks great, especially on ubuntu, so I'll give it a chance! Nomachine This is a remote desktop like teamviewer. The connection via SSH is not available in the free version. The screen was recognizably pixelated (the one you know from high jpg compression), so I guess this would not be fun to work with. I've given up this idea of remote editing from one single computer. So after all I get the feeling that the best experience will be to have a local dev environment. Whatever that might be... Another problem is that if you are working in a team environments WILL be different. So devilbox could help in such a scenario, while a single specialized dev-vps that is highly customized for my needs would not help at all. Yeah. Tried docker now and it looks quite nice. Still a little complicated for me, but devilbox builds on docker + docker-compose and I totally get why it is so popular ? Yeah. All those things always sound great at the beginning but then there is some point where you start hitting walls. I was using the portable version for some time, but then It was not integrated in the context menu (I use "open in vscode" quite often) and some other parts where also not perfect (no auto updates, etc... things that you don't realize first but that start getting annoying lateron). Interesting. Maybe Ubuntu was the problem. Or the cloud server setup. Who knows ? Also very interesting, thx! But does "Find in Folder..." work on that setup? And what about the fuzzy file search (ctrl + P, then type "wir arr")? Does it work? Is it performant? Can't believe that those things are nearly as performant as on a local machine... I have some ssh plugins installed. They are good for some special tasks but not more than that. It's not a replacement for a local dev setup. I use one to quickly edit files online (that's great if you need it, just browse the file tree as if it where on your pc, open the file, save it, done) and one to connect to my servers via ssh in the integrated terminal (ctrl + shift + p, type "sshlogin", choose the server and you are logged in).
  21. Thx. Didn't know about that. But I guess I'd then need to copy the whole .htaccess content over? Or does it load .htaccess additionally? Before or after the .htaccess? Or can that be defined?
  22. Update on the intelephense issue of core modules: https://github.com/processwire/processwire-issues/issues/860 The mentioned quickfix is to copy all .module files in a temp/hidden directory, eg /site/assets/.intelephense and add the .php file ending. It works: In my installation I have 139 .module files - quite a lot that is not indexed by Intelephense! Moving those files to a new folder when anything has changed would be quite easy. Intelephense would always be up to date with the current install (there could be custom modules in /site/modules as you can see in the screenshot). A custom module for this would be too much, I guess. I think that would fit great into @adrian 's TracyDebugger. What do you (and others) think? In the meantime I've filed an issue in their repo, you might give me support there: https://github.com/bmewburn/vscode-intelephense/issues/454
  23. Hi everybody ? Just realized that redirecting to HTTPS does not work when ProCache is enabled (of course it does not work, but I didn't think of it...). The problem with redirecting via the default .htaccess rule is that it will also redirect to https on your dev environment. But you can easily exclude any domains from this redirect rule like this: # ----------------------------------------------------------------------------------------------- # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below. # ----------------------------------------------------------------------------------------------- RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !.*\.test$ [NC] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Maybe that helps someone else as well.
×
×
  • Create New...