Leaderboard
Popular Content
Showing content with the highest reputation on 02/08/2022 in all areas
-
Hi everyone ?? I hope everyone is doing well here. @ryan It's something I have in mind for months, even if am not actively participating to the community (?), I am still using this tool for quite everything and I know that we can support the project by buying license of Pro Modules. That's said, personnaly I am not using them as I mostly build custom modules, or even use it as is. I would like to have the ability to financially support you and people whish maintain this tool. Eventually, Github's Sponsors could be a good choice; You could choose a one-time payment or a recuring one. What do you think about it ?6 points
-
This week we have some great performance and scalability improvements in the core that enable lazy-loading of fields, templates and fieldgroups, thanks to @thetuningspoon — https://processwire.com/blog/posts/field-and-template-scalability-improvements/2 points
-
@teppo That would do it, thank you :) Yup: Works great.2 points
-
Hey Steve, If you're happy to add some logic to config, this was added recently: https://github.com/adrianbj/TracyDebugger/issues/562 points
-
You're right (of course). Just double-checked with earlier Tracy version, and no slow-downs for non-authenticated requests. Could've been an indirect result, i.e. my authenticated requests might've slowed entire server down considerably, which in turn would result in visible delays for others. Other than that... no idea, but things seem to be working well now ?2 points
-
2 points
-
Yes, I have it working in production on a few up-to-date sites. If you find it doesn't work for some reason, feel free to raise the issue here or on GitHub.2 points
-
@kongondo It could but I would guess your bottleneck is quantity of pages, not fields or templates (?). So unless you literally mean hundreds-of-repeater-fields, for your case I think you'd want to enable the ajax loading features of the repeater (if not already) as that would make a big difference. It was a one-off thing that I used and deleted. Writing in the browser so it may need adjustment, but here's something similar (though a bit simpler than what I used): $fieldtype = $modules->get('FieldtypeText'); $title = $fields->get('title'); for($n = 0; $n < 1000; $n++) { $field = new Field(); $field->type = $fieldtype; $field->name = "test_$n"; $field->label = "Test field $n"; $fields->save($field); $fieldgroup = new Fieldgroup(); $fieldgroup->name = "test-$n"; $fieldgroup->add($title); $fieldgroup->add($field); $fieldgroups->save($fieldgroup); $template = new Template(); $template->name = "test-$n"; $template->label = "Test template $n"; $template->fieldgroup = $fieldgroup; $templates->save($template); } @ErikMH I'm not aware of any recent changes that would affect pages in that manner. But for your code, I would drop the $me = wire($this); there is no $me, there is only $this. ? And rather than referring to $me->parent; refer to $this->parent(); with the parenthesis, so that it is a method call rather than a direct access property. Since you are "inside" of the Page class here, the interface is a little lower level than if you are outside of it. Usually it doesn't matter but in this case of things like "parent" I think it might be safer to method calls rather than properties, because these things are dynamically loaded and so accessing the method ensures that happens.2 points
-
Welcome to the forums! There are various ways you could do this, if I understand what you're trying to achieve correctly, but I'd suggest something like the following (written without any testing): // Get a ProcessWire page array of pages with the X metric $testsWithX = $pages->find("repeater.metric=X"); foreach($testsWithX as $test) { // Set output formatting to false $test->of(false); // Get the relevant effect from the repeater $effect = $test->repeater->get("metric=X")->effect; // Set a sort property for the page (in the page array) $test->effect_for_sort = $effect; // Save (to the page array) $test->save('effect_for_sort'); } // Sort the array of pages $testsWithX->sort('effect_for_sort'); Looping through the pages shouldn't give you any issues with performance at all - unless you have a huge number of pages. One alternative would be to maintain a sort field (containing the relevant effect value) on each page, kept up to date by hooking on page save. Then you could get the sorted array of pages with a single selector. However, something like the above should be fine – and would in any case be a better approach while developing the site because it's easily amended.2 points
-
@horst Well then, allow me to raise your expectations again, because your description is not how it works ? In your scenario, both developers could merge their branches with zero conflicts, and as a result the main branch would incorporate all the changes from both branches. They don't even need to know what the other one is doing, and nobody needs to constantly keep up with changes from other branches / team members. That's because git is really smart in the way it performs merges. Basically, you can view every branch as a set of changes applied to the existing files. As long as those changes don't conflict, you can merge in multiple PRs back to back without any manual conflict resolution. So most of the time, you can just lean back and everything works. The only time you get a merge conflict that needs to be resolved is if there are actual conflicts that require a decision. For example, if developer A renames some_old_field to unicorns and developer B renames the same field to rainbows, that would result in a merge conflict, because a single field can't have multiple names. So someone needs to decide between unicorns and rainbows for the field name. In other words, you don't have any overhead caused by git itself – git acts as a safety net by warning you about merge conflicts so you can fix them. In a well-engineered system with good separation of concerns, it's rare to have non-trivial merge conflicts, since it's unlikely that two people working on separate features will need to touch the exact same files. And most of the time, if you do get a merge conflict it's trivial to resolve – for example, if two PRs add a new variable to our SCSS variables in the same place. This would be a merge conflicts, but it's trivial to resolve, since you know you want both changes. If you know git well, you can resolve those in under a minute, oftentimes with a single command (by specifying the appropriate merge strategy for the situation). It's the exact opposite – the larger the development team, the more you will benefit from this streamlined workflow. Everyone can focus on different features and merge their work in with the minimum amount of effort required by either them or other developers to keep in sync with each other. Regarding all the git stuff, I recommend the Git Pro book (available for free), a great resource to understanding how git works under the hood and discover some of the lesser-known features and power tools. Reading the book front to back helped me a lot to establish our feature-branch workflow (for Craft projects) at work, utilize git to work way more effectively, solve issues with simple commands instead of the xkcd 1597 route and much more. For branching and merging in particular, check out the following chapters: 3.2 Git Branching - Basic Branching and Merging 7.8 Git Tools - Advanced Merging2 points
-
Hello friends! I have another module for you, which will make your daily work as a Processwire developer easier. Introducing: AppApi This module helps you to create api-endpoints, to which an app or an external service can connect to. Features Simple routing definition Authentication - Three different authentication-mechanisms are ready to use. Access-management via UI Multiple different applications with unique access-rights and authentication-mechanisms can be defined The documentation has become quite extensive, so have a look at the Github repository for details: Installation Defining Applications Api-Keys PHP-Session (Recommended for on-site usage) Single JWT (Recommended for external server-calls) Double JWT (Recommended for apps) Creating Endpoints Output Formatting Error Handling Example: Listing Users Example: Universal Twack Api Routes Page Handlers File Handlers A special thanks goes to Thomas Aull , whose module RestApi was the starting point to this project. This module is not meant to replace this module because it does a great job. But if you want to connect and manage multiple apps or need other authentication methods, this module might help you. I am already very curious about your feedback and would be glad if the module helps you a little bit.1 point
-
Hi, I want to share an easy way to use Stripe Payment Links in processwire website: 1) Upload folder 'stripe-php' in site/templates (attached) 2) Upload file init.php in site/templates (attached) 3) Use variables in template 'product': $xxx = $page->prezzo_interno; $session->set(prod, "$page->title"); $session->set(price, $xxx); 4) Insert a form in the template 'product' 5) Copy ApiKey in Stripe Account 5) Create a template 'checkout' and copy Apikey <?php //include './stripe-php/init.php'; include 'init.php'; //require 'vendor/autoload.php'; Stripe\Stripe::setApiKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxx'); header('Content-Type: application/json'); $YOUR_DOMAIN = 'https://www.dominio.it/'; $checkout_session = \Stripe\Checkout\Session::create([ 'shipping_address_collection' => [ 'allowed_countries' => ['IT'], ], 'shipping_options' => [ [ 'shipping_rate_data' => [ 'type' => 'fixed_amount', 'fixed_amount' => [ 'amount' => 500, 'currency' => 'eur', ], 'display_name' => 'Standard', // Delivers between 5-7 business days 'delivery_estimate' => [ 'minimum' => [ 'unit' => 'business_day', 'value' => 5, ], 'maximum' => [ 'unit' => 'business_day', 'value' => 7, ], ] ] ], [ 'shipping_rate_data' => [ 'type' => 'fixed_amount', 'fixed_amount' => [ 'amount' => 800, 'currency' => 'eur', ], 'display_name' => 'Celere', // Delivers in exactly 1 business day 'delivery_estimate' => [ 'minimum' => [ 'unit' => 'business_day', 'value' => 1, ], 'maximum' => [ 'unit' => 'business_day', 'value' => 3, ], ] ] ], ], 'line_items' => [[ # Provide the exact Price ID (e.g. pr_1234) of the product you want to sell 'name' => $session->get(prod), 'amount' => $session->get(price), 'currency' => 'eur', 'quantity' => 1 ]], 'mode' => 'payment', 'discounts' => [[ 'coupon' => '1', ]], 'success_url' => $YOUR_DOMAIN . 'grazie/', 'cancel_url' => $YOUR_DOMAIN . 'pagamento-rifiutato/', ]); header("HTTP/1.1 303 See Other"); header("Location: " . $checkout_session->url); .. and that's it! I hope it could be useful for everybody here! Bye Archivio.zip1 point
-
Eh, and now it is suddenly working without any forgery accusations! I was only fiddling around with php-fpm, trying to make it log errors. "Have you tried turning it off and on again?" Thanks flydev for your time.1 point
-
@ErikMH The line producing the error you mentioned is making a $parent->getTitle(); call. What is getTitle() ? That's not a PW Page method, so I'm wondering if that's a method you've added in your custom page class? If so, and you called this on the page representing your homepage. The value of $page->parent would correctly be a NullPage, as you are seeing there. So even if we track down an issue causing this particular instance, I'm thinking you'll want to update your code to account for the possibility that a getTitle() method may or may not be present. Maybe this? $parent = $this->parent(); if($parent->id && method_exists($parent, 'getTitle')) { $theHTML = '...'; }1 point
-
I'll have to look into the error stuff later as I don't have it figured out with Caddy. Here is the beginning of phpinfo with what I think are the interesting bits:1 point
-
This is a slow bit of reporting back, but it might be useful for anyone who comes across the same issue. In brief, the problem has gone away, but I don't know why. All I did was follow @horst's advice and look at the "sort" column in the database. I watched the column changing and made a couple of manual changes to discover how it worked... And then found that the bug had gone way - and for all pages where it had occurred. Several users experienced the bug, but they have now been using the system for several weeks without it recurring, so it seems to be fixed. I don't like leaving an issue without finding out the root cause, but I haven't been able to work anything out. If sombody has the same issue, try what I did and keep your fingers crossed!1 point
-
1 point
-
@thetuningspoon, massive thanks for the POC! @ryan If I am editing a page with lots of repeaters on it (hundreds), would the new lazy loading improve (ProcessPageEdit) performance? This is aside from the current ajax-loading of repeater fields. Are you able to share (a gist maybe?) the script you used to automate the creation of fields, templates and fieldgroups please? It might help others quickly replicate your test install in order to help with testing this new feature. Thanks.1 point
-
I feel real good about this scalability and speed tuning with the fields and templates. Big thanks fly out to the tuning spoon and ryan.1 point
-
That's my thought each and every time I miss a few weeks of @ryans posts. There is soooo much in PW we don't know but Ryan.1 point
-
It is fixed in verion 1.1.2, add a admin-helper-links permission to a role.1 point
-
I've done a simple version of this by hashing the file's modified time: $js_version = md5(filemtime($config->paths->assets . 'js/script.js')); echo sprintf('<script src="%sjs/script.js?v=%s"></script>', $config->urls->assets, $js_version);1 point
-
Yep, works great! In case anyone is following along, my original example is updated and working correctly. Thanks Ryan!1 point
-
Ryan, Thanks this gave me a great place to start. I thought I'd share the version I created in case anyone finds it useful. • Single template for the login/logout. • Automatically redirects the user back to whatever page they originally requested after they login. ./includes/login.php <?php // Handle logouts if($input->get->logout == 1) { $session->logout(); $session->redirect($page->path); } // If they aren't logged in, then show the login form if(!$user->isLoggedin()){ // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect($page->path); } else { $session->login_error = 'Login Failed. Please try again, or use the forgot password link below.'; } } ?> <!DOCTYPE HTML> <html lang="en"> <head> <title>Custom PW Login</title> </head> <body> <form action='./' method='post'> <div class="login"> <? if($input->post->user && $input->post->pass) { echo "<p class='error'>" . $session->login_error . "</p>"; }?> <p><input type='text' id="user" name='user' placeholder='Username'/></p> <p><input type='password' id="pass" name='pass' placeholder="Password" /></p> <p><input type='submit' class="btn" name='submit' value='Login' /></p> </div> </form> </body> </html> <? die(); // don't go any further if not logged in } // end !logged in ?> In any template you wish to protect: <? require("./includes/login.php");?> To trigger a logout: <a href="?logout=1">Logout</a> Note: I'm using the HTML5 placeholder attribute. Browser support is not 100%. You may want to use labels instead, or use some jQuery (like I did) to add the placeholder text for browser that don't support it. SideNote: How do you get code indents to stick when posting? I'm having to go back and add spaces to each line. I use tabs when coding.1 point