Leaderboard
Popular Content
Showing content with the highest reputation on 03/31/2020 in all areas
-
I have built little forms like this manually a couple of times! It's definitely fun, though building complex forms is a lot more work than one might think, but for small forms you'll be fine. No problem at all - you just need to handle the things that FormBuilder will do. In your example, most notably: Write the HTML for the form. You can try to dynamically generate this, but building exhaustive options for form fields is much work, so for a simple form static HTML will be fine. Handle the result. I'd do that within the template file of the template where your form is output. For a normal form you'd need some form of Spam protection, CSRF protection and other stuff but since in your case you require a password that won't be necessary, since you can just throw out submission that don't match the password. Store the submission, more on that below. Submit the file. For a simple solution, you can just redirect to the URL of the file. I have built something where I wanted to make sure the file can ONLY be accessed through the form. For this, you can put your file in a safe location (outside your webroot) and stream it through PHP once you have checked if the password is correct. Make sure to output the correct header to instruct the browser to start a download. Quick and dirty, based on the readfile documentation: if ($input->post('password_field') === $page->my_secret_password) { $file = '/path/to/file.pdf'; header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Content-Length: ' . filesize($file)); header('Cache-Control: private'); readfile($file); exit; } Honestly, don't overthink this bit. Unless you are expecting thousands of request an hour, you don't need to optimise it. Depending on what you plan to do with this data I might go with a ProFields Table field or a regular template. Those are nice because all content is stored in a single, simple table. This gives you a bit more room to optimise if and when you need to. But if you are really getting so many requests that the server can't handle them, you will probably yield more improvements by building a seperate endpoint that doesn't load ProcessWire at all and instead writes to the database directly. This will be a bit easier with a ProFields Table field, though it really doesn't matter that much. If you are using a ProFields Table, make sure you are not loading the field on your form page, because that will load ALL it's data, that might in fact get out of hand quickly if you have lots of submissions.5 points
-
Hello All, In the middle of this pandemic, I came across a citizen-science site that I think we should all consider helping out. It's called folding@home and aims to produce the largest distributed medical research computer cluster in the world, in order to solve protein folding problems, that should help develop treatments (or cures) for multiple medical conditions we all face. If you, or your company, have any spare internet connected resources, please consider joining the cluster - it's fairly easy to setup the client and connect. I'm running this on my linux laptop and hope to keep doing so. It's quite CPU intensive so you get to choose the level of resource usage it can have. For example, to control my CPU temperature. I've limited to just a single thread on an i7. Please support if you can.3 points
-
@Robin S Awesome module. I never understood why this functionality is not in the core. ?♂️ Thank you for implementing this feature! I sent you a pull request on GitHub, with a bugfix regarding multilanguage setups and float conversion, small performance tweaks, and support for repeaters! Best regards. https://github.com/Toutouwai/ImageCropRatios/pull/23 points
-
Hi there, If I understand correctly you don't want to have selected none page? If that is the case, just drop down pages for select, find that one which is selected and choose "unselect".2 points
-
Yes, of course ... check the documentation page, you can get all or just one product, create a new one, modify it or delete it etc. PRODUCT: https://shopify.dev/docs/admin-api/rest/reference/products/product You can do this simply using WireHttp, I think if you want to add much more information to the product than Shopify allows or to relate it directly to other PW pages, then it makes sense to have a copy in PW and keep the synchronization between them, but if you only want to display products in a section of your website like a regular store only for selling, then you can simply query the API from your template file and process/display the answer on your website. When you check the DOC page you will see very clear examples of how to use the queries, you will see that you can use filters, and the answer is JSON that you can easily manipulate in PW. For the synchronization issue you can export the list of products to a CSV file and import it in PW, in my tests I used Ryan's module and it worked perfectly. Shopify also has Webhooks that allow you to update PW from Shopify according to events in the store such as new product, modifying or deleting it, new order etc. WEBHOOK: https://shopify.dev/docs/admin-api/rest/reference/events/webhook In other words, there are many ways to interact with Shopify and they are all very simple, well.. it seems to me, that I'm a graphic designer and not a professional programmer.2 points
-
Inspired by a recent question. Image Crop Ratios Allows preset aspect ratios to be defined per image field for the ProcessWire image crop tool. The module adds a select dropdown to the crop tool. Choose an aspect ratio and the crop area will be fixed to that ratio. Screencast Installation Install the Image Crop Ratios module. Configuration Default aspect ratios for all image fields can be defined in the module config. Aspect ratios for specific image fields can be defined on the Input tab of the field settings. You can override the ratio settings in template context if needed. Insert a hyphen as the first item in the ratio settings unless you want to force a ratio to be applied to the crop tool. The hyphen represents a blank option that allows a free crop area to be drawn. Usage Click the "Crop" link on the details view of an image thumbnail. Click the "Crop" icon at the top of the editor window. Choose an option from the "Ratio" select dropdown. https://github.com/Toutouwai/ImageCropRatios https://modules.processwire.com/modules/image-crop-ratios/1 point
-
I've used this library with success to import products or update them regularly like on a cron job: https://github.com/donutdan4114/shopify Takes care of rate throttling too which is nice!1 point
-
Thanks @David Karich! Hm, right now the module is just calling $procache->clearAll() which is supposed to clear everything according to the ProCache store page. Is there another method to clear the minified assets as well? I checked all documentation I could find, a couple of ideas: I don't know how ProCache works with minified assets, but according to this blog post any changes to the CSS & JS files should be picked up automatically, so maybe it's not necessary to clear those? Though of course that is not ideal for a cache clear button ? Judging by the last screenshot on this blog post, ProCache stores minified assets inside /site/assets/pwpc, or is that out of date? Currently, ProcessCacheControl only supports clearing out folders inside /site/assets/cache (so it can't accidentally nuke the files directory because of a misconfigured setting ...). Maybe I could extend that to also allow clearing /site/assets/pwpc. Is that directory path static or can it be changed? Anyway, I'll put out a stable release with updated documentation & the ProCache integration soon! Hopefully the minification issue can also be resolved then.1 point
-
I really have a Shopify class implemented, but basically you can do this as simple as: // https://shopify.dev/tutorials/authenticate-a-private-app-with-shopify-admin $key = "yourkeyhere"; $pass = "yourpasswordhere"; $store = "yourstorename"; $data = array( "since_id" => "632910392", // Retrieve all products CREATED after the specified product (by ID) "fields" => "id,images,title", // include only this attributes in the response ); // Is better to use try/catch here $http = new WireHttp(); $response = $http->getJSON("https://{$key}:{$pass}@{$store}.myshopify.com/admin/api/2020-01/products.json", true, $data); // True to get an array, False for object $products = $response["products"]; if (count($products) > 0) { foreach ($products as $product) { echo $product["title"]; // direct output or save to a custom array to use in views, etc. } } // use the id field for the Buy Button js code in order to have the cart/checkout in your site1 point
-
@MoritzLost Nice work! Tested: the page cache is deleted, but not the compiled assets (js, css) of ProCache. PW DEV 3.0.153, ProCache latest, Win and Linux, PHP 7.3, PHP 7.41 point
-
1 point
-
1 point
-
I hate hate hate hate (repeat however many times you would like) to say this, but WooCommerce is my weapon of choice for eCommerce. For the level of my client base, they are on the understanding that if I say I am not doing that with this software and you would need something more highend and secure, then they are ok with the functionality. That will be the only time you will ever hear me talk WordPress on here (until the new Padloper comes along). But, I did check out the module by @Gadgetto that @bernhard was talking about, and it is impressive. Yes you can plug everything into the frontend yourself with Snipcart, but the backend integration is lovely. If you are worried about the fees, then in my experience, you have a product that has too many competitors and there will always be somebody out there undercutting you. Just roll something out with a slightly higher price otherwise, test the water and adapt from there.1 point
-
The ID of trash is 7, not 49. Depending on your need, you could do: $untrashedPages = $pages->find("template=some-template, status<" . Page::statusTrash); //$untrashedPages = $pages->find("template=some-template, has_parent!=7"); //$untrashedPages = $pages->find("template=some-template, has_parent!=" . $config->trashPageID); FYI, statusTrash = 81921 point
-
Getting just the folder means $file is actually not a file (Pagefile), but a Pagefiles object. File fields are internally always handled as list of files, so you might need to use the following or alike: $file = $upload->file->first();1 point
-
As if Corona wasn't enough, this morning Zagreb was hit by an earthquake. It seems that several hospitals were also damaged. Now instead of staying at home, several people are forced to go outside.0 points