Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/17/2023 in all areas

  1. This week ProcessWire 3.0.214 is on the dev branch. Relative to 3.0.213 this version has 16 new commits which include the addition of 3 new pull requests, 6 issue fixes, a new WireNumberTools utility class, and improvements to various other classes. A newly added $files->size($path) method was added which returns the total size of the given file or directory. When given a directory, it returns the size of all files in that directory, recursively. Improvements were also made to ProcessWire's log classes (WireLog and FileLog) with new methods for deleting or pruning all log files at once. This version also fixes an issue with the front-end page editor (PageFrontEdit) when used with InputfieldTinyMCE. For more details on these updates and more see the dev branch commit log. Something else I've been working on this weekend is a vulnerability scanner blocker and throttler. I don't know if this is an issue for every site, or if it's because this is an open source project site, but we seem to get a lot of vulnerability scanner bots hitting the site. Sometimes they hit the site pretty hard (with hundreds of thousands of requests) and our AWS cluster servers and databases must scale to meet the demand, using more resources, and thus increasing cost. This is annoying, having to scale for a hyperactive vulnerability scanner rather than real traffic. And it always seems to happen in the middle of the night, when I'm not nearby to manually block it. So I'm working on a module that detects vulnerability scanner traffic patterns and then blocks or throttles requests from their IPs automatically. Once I've got it functioning smoothly here, I'll also plan to add it to ProDevTools board download thread in case it's useful to anyone else. Thanks for reading and have a great weekend!
    10 points
  2. I oftentimes create a checkbox field called 'test' and assign it to certain templates. I check the box if the page is a test page. These pages may exist on the live site and I don't want to hide or unpublish them, but at the same time, I don't want them to appear in the XML Sitemap. (not part of this tutorial, but I also noindex,nofollow those pages using a meta tag in the head so search engines don't index them) In that case, you can remove them from the WireSitemapXML like this in /site/ready.php: $wire->addHookAfter('WireSitemapXML::allowPage', function(HookEvent $event) { $page = $event->arguments('page'); if($page->hasField('test') && $page->test) $event->return = false; });
    6 points
  3. Sounds great for sure! Thank you in advance.
    2 points
  4. That's because there isn't one yet. I have the search functionality somewhere back in my mind. Promised! I thought I keep it simple. As mentioned above the search functionality will come, yet I'm not sure about which way I go here. For now the whole setup is more a proof-of-concept but we will get there. You are absolutely right about that. For now in an upcoming version I went another route with this as just plain white and shadows didn't work out that well on the eyes as well. I have some thoughts and ideas here to solve this dead end kind of browsing. I guess we will have this next week. Depends on other projects. You can just send a pull request with an updated version of the recipe. There is no rule against several solutions in one recipe. In my opinion this would be actually really awesome to show and tell that there are different ways. So feel free to either submit a new or updated recipe. I really appreciate both! In case you update the existing recipe you want to update the version, if available or give a new one, and add yourself to the authors. I updated the recipe sample here. In case you or someone else need additional data points like ProcessWire min/max versions or similar. Just add it to the recipe, let me know in the PR and we get it sorted. Thanks guys for all the great feedback and ideas!
    2 points
  5. (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website ?. Thx @teppo !) FieldtypeQRCode Github: https://github.com/eprcstudio/FieldtypeQRCode Modules directory: https://processwire.com/modules/fieldtype-qrcode/ A simple fieldtype generating a QR Code from the public URL of the page, and more. Using the PHP library QR Code Generator by Kazuhiko Arase. Options In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default. You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field. If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated. Formatting Unformatted value When using $page->getUnformatted("qrcode_field") it returns an array with the following structure: [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "raw" => string, // the raw qrcode image (in base64, except if svg+markup) "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup. Should you need the same markup as in the admin you could use: $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value. Static QR code generator You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are: string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks Please have a look at the source code for more details about the hookable functions. Examples $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    1 point
  6. Hi guys, feel free to make PR. Unfortunately, I'm not able to find a time for this now.
    1 point
  7. Is it possible to realize this e-commerce with Padloper 2 I want to sell 10 products (food in a school restaurant). The food is sold on monday, tuesday; thursday and friday. Orders are places per month. First the month is chosen per product you can choose the days you want to buy the product Orders can be shown in different lists per customer / date / product/ per food / number per day per date / food (per date #bread 1, #bread2, ...) Lists can be emailed to customer, to ...
    1 point
  8. We're using a similar approach: install ProcessWire via Composer and then use post-install-cmd and post-update-cmd to copy the wire folder from vendor to web root. It would be preferable not to have to do the whole post-[install/update]-cmd step (or have entire wire directory in public directory for that matter) but to be honest this works quite well. Some files in wire need to be web accessible, so I'm not aware of any clean way around this. To be clear this is about installing and/or updating ProcessWire on a site that has already been set up. As for setting up a complete, new ProcessWire setup via Composer... I've no experience about that. Technically you could install ProcessWire via Composer and then copy everything from vendor/processwire/processwire/ to your web root, but for my use cases that has never really made sense ?
    1 point
  9. https://github.com/elabx/FieldtypeRecurringDates Well a few summers later, finally got like a sort of working version. For info please take a look at the repo's readme. It's still super alpha but going to deploy into a couple websites to replace Recurme so wish me luck. This module is only a Fieldtype and Inputfield, there are no "markup" modules as there used to be in Recurme. I'd appreciate any testing or any kind of comments.
    1 point
  10. v3.19.0 comes with a new magic method to easily set the page name whenever a page is saved: public function setPageName() { if (!$this->year()) return uniqid(); return $this->title . "-" . $this->year(); } It will also lock the page name field and show a hint so that everybody understands what's going on:
    1 point
  11. It's pretty straight forward. Instead of defining textual options, you create a page for every selectable option. Preferably, you group them under their own parent, and you'll usually want to assign them their own template, both to make queries easier and so you can add more fields to the template later. In your case, you can start with a (backend-)template "region", no need to add a PHP template file since the region pages are only for filling the dropdown. You'll also want a template "regions" for the regions' parent page. This one will be the overview page you're trying to build and therefore need a PHP template. In the first step, just create both templates with the minimum fields PW suggests (i.e. just a "title" field which will be the label in your dropdown). Then create the pages. Home - Regions - - Region 1 - - Region 2 - - ... In your hotel template, add a page reference field for the region, and on the "Input" tab in the field's configuration, go to "Selectable pages". Under "Templates", select "region". Edit your hotels and assign a region to each. Now you can easily iterate over all available regions in your regions.php template file, output the region's details and a list with the hotels for that region. A little PHP snippet as a starting point: <?php namespace ProcessWire; foreach($page->children() as $region) { echo "<h3>{$region->title}<h3>"; echo "<ul>"; $hotels = $pages->find("parent=/hotels/, region=$region"); foreach($hotels as $hotel) { echo "<li><a href='{$hotel->url}'>{$hotel->title}</a></li>"; } echo "</ul>"; }
    1 point
  12. Double slashes used to “just work” but they redirect to the clean url since 3.0.212. Haven’t looked into the code, I suppose the query string gets lost along the way?
    1 point
  13. Live Server Extension for VS Code + a browser extension for it are a tool to refresh any page in the browser when the watched code in VS Code changes. It can work with php-generated content - see here on how to set it up. Nothing unique to ProcessWire though.
    1 point
  14. Thought I'd post here how I solved my issue in the end by doing the arranging in the frontend and saving the data back to be used by the template.
    1 point
  15. On the parent page template, if you select a single allowed template for children and specify a "Name format for children" then the first step of the "Add New" page process should be skipped. To set the name the core name format setting might be sufficient, or you have more options with kixe's module, or you can use your own hook: $this->pages->addHookBefore('setupNew', function($event) { $page = $event->arguments('page'); if($page->template == 'my_template') { $page->name = 'some-name'; } });
    1 point
  16. For security, I'd avoid implementing solutions that would let anyone enable debug mode. So GET vars aren't ideal unless you can get enough "security by obscurity" with the GET variable (perhaps by name or value). My IP address doesn't change often, so I usually enable debug mode directly from my /site/config.php with a line like this: $config->debug = $_SERVER['REMOTE_ADDR'] === '123.123.123.123';
    1 point
×
×
  • Create New...