Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/25/2022 in all areas

  1. Hi @Sylvie, Welcome to the ProcessWire forums. Please send @ryan a personal message. Thanks.
    2 points
  2. Hi Robin, I think one can do that a bit simpler, at least I always use it this way: 1) I'm not hundred percent sure, but maybe there is difference between cloning the whole template compared against only duplicate the fields. (Cloning definitely includes all settings under family, files, advanced, etc) 2) And this saves the creation of an extra template file. All in all very useful when I want to use something like a single controller file, that calls different view files upon the template names. ?
    1 point
  3. Thank you for this code - it's very useful! One thing I noticed is that when a relevant page is sent to trash, that page doesn't have the option to restore from trash. I think this might be because when pages go to trash they appear to be renamed by ProcessWire. Removing the final line (uniquePageName) seems to solve the issue, but you lose that functionality of course. So based on a post of yours in another thread: ...I added an "isTrash" conditional, as below. Is this a reasonable solution or is there a better way? // Creature if($page->template == 'creature') { // Don't change name field if page is going to trash if(!$page->isTrash) { // If the fields that make up the title are populated if($page->colour->id && $page->animal->id) { // Set the title $page->title = "{$page->colour->title} {$page->animal->title}"; // Sanitize the title as a page name $name = $event->wire()->sanitizer->pageName($page->title, true); // Set the page name while making sure it auto-increments if there is a sibling page with the same title $page->name = $pages->names()->uniquePageName($name, $page); } } } });
    1 point
  4. Thanks for your answers! I think this was because of some smpt limits at the provider. I now solved it with wiremail without smtp an it work pretty well.
    1 point
  5. Why is that? Why not create a copy of the template (Setup > Templates > Add New > Copy fields from another template) that has access control enabled and then edit the pages to use that template? And the template file can just consist of: include './your_other_template_file.php';
    1 point
  6. For those who do no have access to the Pro fields support forum, Ryan expains a similar issue like this: "One thing about repeaters is that they sometimes have extra pages in them called "ready pages", which are basically abandoned new items that are saved for the next time you need to add an item to the repeater. So in your loop that iterates the repeater items, you'll want to check that the items are published and/or not hidden before considering them valid for your calculations. if($child->isUnpublished() || $child->isHidden()) continue." see: https://processwire.com/talk/topic/24967-hook-says-there-are-twice-as-much-repeater-items/?do=findComment&comment=210451
    1 point
  7. v0.0.12 now available. This fixes a few bugs and also introduces interactive dependent-selects in the config. Now that both the config and the pages have dependent selects, I thought it would be helpful to demo how it all works. Firstly, the config. On the details tab, you select the quantity you want to measure and then choose what units you want to be selectable within a page (you can also choose whether to convert automatically, not at all, or to 'ask'): New field.mp4 You will realise that we ended that demo just saving with no quantity selected. That's because we can use the same field in different template contexts to measure different quantities. So, next, we are going to add our field to a template and choose 'volume' as the quantity: volume template.mp4 Similarly, we can add our field to a different template to measure mass: mass template.mp4 Finally, we can create a page using one of these templates. In this case, it is 'volume' and we have chosen to convert automatically: volume page.mp4 If we had chosen to 'ask', we would have got a confirmation box before doing the conversion. All of this is accomplished by the magic of htmx (and of course ProcessWire). The principles behind it are discussed at The actual code has moved on a bit from that post. For instance, I have used css transitions in the config. These work really nicely with htmx: #Inputfield_unit_set { opacity: 1; transition: opacity 200ms ease-in; } #Inputfield_unit_set.htmx-swapping { opacity: 0.1; transition: opacity 100ms ease-out; } #Inputfield_unit_set.htmx-settling { opacity: 0.1; } Now I'm getting the hang of htmx, I really like it ?
    1 point
  8. Back with more! Prepare for incoming wall of text... I mentioned adding custom directives to our .htaccess file and wanted to share some more detail on that as well as some other tips. I was reviewing our 404s as a matter of maintenance so to speak to ensure that we had redirects in place as necessary. While reviewing that I found a lot (a lot) of hits that were bogus, clearly bots and even web crawlers for engines we have no interest in being listed for. What I found was in just 48 hours we had 700 total 404s and I imagine on some websites that number could be higher. By analyzing that log and writing custom directives I was able to take 700 404s logged by ProcessWire down to 200 which are "legitimate" in that it's traffic that to be redirected to a proper destination page. I'm sharing my additional directives here as an example. Again, ANY bot/security directives should be at the very top of your .htaccess file. As always, test test test, and modify for your use case. # Declare this at the top of your .htaccess file and remove or comment out all other instances of this directive elsewhere RewriteEngine On # Block known bad URLs # Directories including sub-directories RedirectMatch 404 "\/(wp-includes|wp-admin|wp-content|wordpress|wp|xxxss|cms|ALFA_DATA|functionRouter|rss|feed|feeds|TKVNP|QXXLZ|data\/admin)" # Top level directories only - There are no assets served from these directories in root, only from /site/assets & /site/templates RedirectMatch 404 "^/(js|scripts|css|styles|img|images|e|video|media|shwtv|assets|files|123|tvshowbiz)\/" # Explicit file matching RedirectMatch 404 "(1index|s_e|s_ne|media-admin|xmlrpc|trafficbot|FileZilla|app-ads|beence|defau1t|legion|system_log|olux|doc)\.(php|xml|life|txt)$" # Additional filetypes & extensions RedirectMatch 404 "(\.bak|inc\.)" # Additional User Agent blocking not present in 7G Firewall <IfModule mod_rewrite.c> # Chinese crawlers that cause significant traffic to bad URLs RewriteCond %{HTTP_USER_AGENT} Mb2345Browser|LieBaoFast|zh-CN|MicroMessenger|zh_CN|Kinza|Datanyze|serpstatbot|spaziodati|OPPO\sA33|AspiegelBot|aspiegel|PetalBot [NC] RewriteRule .* - [F,L] </IfModule> Details on this additional config: It blocks some WP requests that get past 7G My added directives redirect to a 404 which tells the bot that it flat out doesn't exist rather than 403 forbidden which could indicate it may exist. I read somewhere that this is more likely to get cached as a URL not to be revisited (wish I could remember the source, it's not a major issue). Blocks a lot of very specific URLs/files we were seeing Blocks Chinese search engine bots, because we don't operate in China. These amounted to a lot of traffic. Blocks common dev files like .bak and .inc.* which aren't protected by default. Obvs you want to eliminate .bak altogether in production, but added safety fallback. I have not seen this cause any issues in the Admin. Also consider if directives could cause problems in another language. Customize by reviewing your logs Additional measures 7G and the directives I created are a healthy amount of prevention of malicious traffic. Another resource I use is a Bad Bot gist that blocks numerous crawlers that add traffic to your site but may or may not generate 400s-500s HTTP statuses. This expands on 7G's basic list. Bad Bot recommendations: Comment out: SetEnvIfNoCase User-Agent "^AdsBot-Google.*" bad_bot There's not really a good reason to block a specific Google bot If you make Curl requests to your server then comment this line out: SetEnvIfNoCase User-Agent "^Curl.*" bad_bot Reason: this will block all Curl requests to your server, including those by your own code. Be sure that you don't need Curl available if leaving this active. This is included in the list to prevent some types of website scrapers. If you want to leave this active and still need to use Curl, then consider changing your User Agent. Comment out: SetEnvIfNoCase User-Agent "^Mediapartners-Google.*" bad_bot Again, not necessary to block Google's bots, might even be a bad idea for SEO or exposure (only they know, right?). Testing There's no such thing as too much testing. These directives are powerful and while written well, may have edge cases (like 'null' mentioned previously). There's no replacement for manual testing, specifically it would be a good idea to test any marketing UTMs or URLs with GET strings you may have out there just in case. For automated testing I use broken-link-checker which can be called from the terminal or as a JS module. I prefer this method to using some random site scanning service. This will detect both 404s and 403s by scanning every link on your page and getting a response which is useful for ensuring that your existing URLs have not been affected by your .htaccess directives. broken-link-checker recommendations: Consider rate limiting your requests using the --requests flag to set the number of concurrent requests. If you don't you could run into rate limits that your managed hosting company, CDN, or you (if you're like me) have built into your own server. This terminal app runs fast so if you have a lot of links or pages those requests can stack up quickly. Consider using the -e flag, at least initially while testing your directives. This excludes external URLs which will help your test complete faster and prevent any false positives if you have broken external links (which you can handle separately). Consider using the -g flag which switches the request to GET which is what browsers do. Shortcut, just copy and paste my command: blc https://www.yoursite.com -roegv --requests 5 If you have access to your Apache access log via a bash/terminal instance then you may consider watching that file for new 404/403 entries for a little bit. You can do this by navigating to the directory with your access log and executing the following command (switch out the name of your log as needed): tail apache.access.log -f | grep "404 " You may consider also checking for 403s by changing out the HTTP status in that command. "This seems excessive" I think this is good for every site and once you get it dialed in to your needs can be replicated to others. There's no downside to increasing the security and performance of your hosting server. Consider that any undesirable traffic you block frees up resources for good traffic, and of course reduces your attack surface. If you need to think about scalability then this becomes even more important. The company I work for is looking to expand into 2 additional regions and I'd prefer my server was ready for it! If you get into high traffic circumstances then blocking this traffic may prevent you from needing to "throw money at the problem" by upgrading server specs if your server is running slower. Outside of that, it's just cool knowing that you have a deeper understanding of how this works and knowing you've expanded your developer expertise further. This isn't meant to be an exhaustive guide but I hope I've helped some people get some extra knowledge and save everyone a few hours on Google looking this up. If I've missed anything or presented inaccurate/incomplete information please let me know and I will update this comment to make it better.
    1 point
  9. To add my two cents here... I'm totally on board with this and I started to donate in 2019, through 2021 to some devs for their modules. Most often through their publicly available and mentioned ways, such like PayPal, BuyMeACoffee, ... There is one thing with this... as I wrote some of them about it just to tell and check... they said: "Oh... don't have that account anymore!" or "Oh... that changed!". So... to all of us in some kind: please check if those PayPals and Co. still are up to date. To those that donate: write a message to your favourite devs. Feels awkward, but at least you can be sure the money goes where it should go. Another almost unrelated thing: I stopped using my DEV-licenses for client projects. Sure... that's what they are for but... even a hairdresser can afford FormBuilder and ProCache. Why stop there? I use those only for my very personal projects now and I feel much better with this.
    1 point
  10. Hi @Ivan Gretsky - thanks for your monthly donation to Tracy - it's always appreciated.
    1 point
  11. I was about to create a similar topic, but why do it if this one already exists))) Not so long ago I started donating to some ProcessWire modules' authors. And each 1st of the month I am looking at my Patreon receipt in my email with a kind of a pride. I think that this thing is my little contribution to the community I love so much and which gave so much to me for free. I do know that Ryan likes to receive his support with pro modules payment. But many modules really shouldn't be paid/pro as they are so essential to many (and so fun to build). But their authors still would be glad to receive some money to sustain their enthusiasm supporting them and creating new features. I am sure the appreciation itself is equally important, but what is an easier way to show it than ???))) The other thing is that I sometimes notice some great improvements that seem to happen to modules as soon as some support comes in. I am writing this to encourage everyone to support the PW ecosystem by donating to module authors. I will list the modules I know that clearly asked for donations. I am sure that is not an extensive list. But at least something to start with. Tracy Debugger Mystique and other modules by ukyo (please don't miss this one @Jonathan Lahijani))) Rock Migrations and a bunch of rock stuff by bernhard All the great stuff from teppo I really like the Patreon/OpenCollective/Github donations, but only 1 of 3 listed used them. Sooooo..... Start throwing money at these fine gentlemen)) Support yourself by making you favorite modules not go away. I wish we could bring back @tpr to support his AOS and wire shell by @marcus and @justb3a. Would they keep supporting their thing is they had some donations coming in? Who knows. And please feel free to list you other module authors that you know asked for support below. Edit 2022-10-27: added teppo's link
    1 point
  12. My workaround was because of unsorted query results from a Page Reference field inside a Repeater Matrix field. If you can use $pages->find(), the results should get sorted: Try loadOptions and set joinSortfield to true. Test: $items = $pages->getById([1182,1061,1079,1082]); d($items); The result is a PageArray, the items => array is sorted in the order of the ids in your selector. Update: It doesn't seem to work with $pages->find(), but you can use $pages->getById.
    1 point
  13. @adrian thanks a lot for sharing this and for pointing me in the right direction! To clear the original values you can just pass "null" to the "to" method: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/WireMail.php#L152 Same works for cc & bcc, but to be honest, I only tested this in combination with WireMailSmtp. It might look different without WireMailSmtp (e.g. no cc/bcc) The whole hook function looks like this and it works as expected. $this->addHookBefore('WireMailSmtp::send', null, function($event) { if(!$this->config->debug) { // when not in debug mode do nothing return; } $mail = &$event->object; // store orgiginal recpients $recipients = array( 'to' => $mail->to, 'toName' => $mail->toName, 'cc' => $mail->cc, 'ccName' => $mail->ccName, 'bcc' => $mail->bcc, ); // reset all original recipients $mail->to(null); $mail->cc(null); $mail->bcc(null); // add debug recepient $mail->to = 'Dropbox <dropbox@my-domain.com>'; // create debug information for mailbody $debug_body = '### DEBUG INFO ###<br />'; $debug_body .= 'TO: '.implode($recipients['to'], ', ').'<br />'; $debug_body .= 'CC: '.implode($recipients['cc'], ', ').'<br />'; $debug_body .= 'BCC: '.implode($recipients['bcc'], ', ').'<br />'; $debug_body .= '### / DEBUG INFO ###<br /><br />'; // replace original mailbody $new_mailbody = str_replace('<body>', '<body>'.$debug_body, $mail->bodyHTML); $mail->bodyHTML($new_mailbody); return; });
    1 point
  14. Thanks but unfortunately I don't see that happening, and it's not about the donations. I'm working with .NET for at least about 3 years now as the backend, and Angular/Next.js/etc for the frontend, all these on a corporate laptop. My own old laptop where I have PHP is now slow as hell, I boot it up only a few times a year. This "setup" makes it very inconvenient to maintain AOS, and I'm completely out of what's happening with PW and PHP lately, which complicates things even more.
    0 points
×
×
  • Create New...