Jump to content

gebeer

Members
  • Posts

    1,542
  • Joined

  • Last visited

  • Days Won

    47

Everything posted by gebeer

  1. I don't think a PHP update can have an impact on folder permissions. More likely this is an Apache and/or PHP-FPM missconfiguration issue. File/Folder permissions are documented here https://processwire.com/docs/security/file-permissions/
  2. That is not true anymore since 3.0.208. Docs for https://processwire.com/api/ref/sanitizer/email/ options say: I have verified that sanitizer accepts with the allowIDN option set to 2. $sanitizer->email('hans.müller@müller.com', ['allowIDN' => 2]; But the occurences of $sanitizer->email() in InputfieldEmail.module and FieldtypeEmail.module need to be adjusted to allow saving of those values to the DB. We are working on an app for an international corporation and need to import around 15.000 email addresses, some of which have characters like ä, ø etc. Their mailservers support these, so we have to support them also. I'm totally not into reading RFCs, but doing some research I found that since RFC6532 (2012) internationalized email headers are a standard and even the local part of the email can be in UTF-8. For anyone who wants to dig deeper, here are some links to get you started: https://stackoverflow.com/questions/69855149/email-with-special-characters-rejected-rfc-6532-and-quoted-printable https://github.com/roundcube/roundcubemail/issues/5120 https://www.rfc-editor.org/rfc/rfc6532
  3. Hi all, I'm on PW 3.0.209 and cannot save international Email strings (like "hans.müller@müller.com") to email fields through the GUI and also not through the API. Since 3.0.208 $sanitizer->email supports IDN with option "allowIDN". But the accepted values cannot be saved. As far as I can see from the code, this also applies to latest dev version. Can anyone confirm this behaviour? I opened an issue request with a proposed fix for the API side of things https://github.com/processwire/processwire-issues/issues/1680
  4. I totally agree and would have expected RM to work like that. No use for a module-related migration if the module is not installed.
  5. Are you using MJML for compiling your email HTML. You can compile theam as .php files. Is it a namespace issue, do you have namespace ProcessWire in those email HTML files?
  6. Can you rename the include file to .php? Then PW should pick it up for translation.
  7. Have you tried $body=$files->render('path/to/my/mail-template.html''); ? Are your files namespaced?
  8. I found the reason. It works if you only have 1 repeater matrix field. If you have multiple, you need to pass the field object as 2nd parameter: $field = $fields->get('content_product'); $repeaterMatrix = $modules->get('FieldtypeRepeaterMatrix'); $typeId = $repeaterMatrix->getMatrixTypeByName('teaser_gallery', $field); Same goes for $repeaterMatrix->getMatrixTypeLabel(string 'typename', Field $field)
  9. Thanks for sharing. Your 2nd example can also be written like this $fieldName = 'content_product'; $typeName = 'product_downloads'; $pagesWithType = $pages->find("{$fieldName}.type={$typeName}"); db($pagesWithType); No need for looping through all pages. find() accepts the subselector .type. Only drawback with my solution: you don't get the label for the type. Actually when trying your example, $typeId returned false and $typeName returned null $repeaterMatrix = $modules->get('FieldtypeRepeaterMatrix'); $typeId = $repeaterMatrix->getMatrixTypeByName('product_downloads'); db($typeId, '$typeId'); // returns false $typeName = $repeaterMatrix->getMatrixTypeLabel($typeId); db($typeName, '$typeName'); // returns null Which version of Repeater Matrix are you using?
  10. On Linux I'm using a combination of https://www.maartenbaert.be/simplescreenrecorder/ (available for most distros) https://www.openshot.org/ (also available for Windows/Mac) Have been looking for a all-in-one solution for a long time. https://obsproject.com/ is a complete solution but it is rather complex for the simple task of creating screencasts. SimpleScreenRecorder allows pause/resume and Openshot is a great easy to use tool for editing / adding captions etc.
  11. Your problem might be related to Autocomplete and PageListSelect inputfields not allowing for custom selector strings. See Just a guess
  12. You get this error because you are using $cache inside the hook function. There you need to use wire('cache') or $this->wire->cache, depending on the context.
  13. Instead of the nested foreach you could do foreach ($tags as $tag) { $usage = $matches->find("tax_tag={$tag}")->count; $label = "{$tag->get('title')} {$usage}"; … } As for optimizing speed, how many pages are there potentially in $matches and in $tags, hundreds or thousands? To speed up queries, you can use $pages->findRaw() and only get the properties that you need for output and then work with those arrays in memory. Example: // find all pages with template document that have a tax_tag assigned // returns associative array indexed by page id with fields title, body and tax_tag where tax_tag is an associative array indexed by tax tag id with fields id and title // [ // 1234 => [ // 'title' => 'Page title', // 'body' => 'Page body content', // 'tax_tag' => [ // 4567 => [ // 'id' => 4567, // 'title' => 'Tax tag title', // ], // ... // ], // ], // ... // ] $matches = $pages->findRaw("template=document, tax_tag!=''", ['title', 'body', 'tax_tag' => ['id', 'title']]); Now you can use the resulting associative array $matches and do operations on it in memory without further DB calls. If you want to get a unique array of tags with usage count that are inside $matches, you could do something like this: // loop through matches to construct available tags array $tagsAvailable = array(); foreach($matches as $m) { // loop through tax_tags of each item foreach($m['tax_tag'] as $key => $tag) { // if key found in $tagsAvailable, tag is already there and we continue if(array_key_exists($key, $tagsAvailable)) continue; // get count of occurences of tax_tag id inside $matches items // and assign count as field 'usage' to the tag $tag['usage'] = count(array_filter(array_column($matches, 'tax_tag'), function($arr) use($key) { return in_array($key, array_keys($arr)); })); // add tag to available $tags $tagsAvailable[$key] = $tag; } } $tagsAvailable will look somewhat like this [ 1137 => [ 'id' => 1137, 'title' => 'Tag Title 1', 'usage' => 4, ], 1140 => [ 'id' => 1140, 'title' => 'Tag Title 2', 'usage' => 7, ], ] Now you can use $tagsAvailable to render your tags and $matches to render your result list. EDIT: I did this with $matches only containing 22 items and $tagsAvilable resulting in 5 items and the whole operation took 0.01ms and used 2.6kB of memory. So this should scale to hundreds or even thousands of matches. Though if you have that many matches you might consider chunk processing and paginating them.
  14. Hi, you can completely customize the comment form and comments list. Have a look at https://github.com/processwire/processwire/blob/master/wire/modules/Fieldtype/FieldtypeComments/CommentFormCustom.php and https://github.com/processwire/processwire/blob/master/wire/modules/Fieldtype/FieldtypeComments/CommentListCustom.php The classes are well documented. This should get you started.
  15. Honestly, when I read your first question, I thought this was spam because I couldn't make sense of it. Sorry for that. May I kindly ask you to edit your last post and remove my clearname from the quote? When pasting from ChatGPT, that got transferred. I thought I had deleted it, but... Would be very much appreciated. Once that is done, I am happy to answer your question.
  16. Your question doesn't make sense. I thought it a good test case for ChatGPT. Here's the AI's answer: Webcomic Site Software Comparison Would ImageMagick work good for a webcomic site or is FileZilla the better option? How do they work and what’s the pros and cons of them? ImageMagick and FileZilla are two different types of software. ImageMagick is an image manipulation program, while FileZilla is a file transfer protocol (FTP) client. ImageMagick can be used to process and manipulate images, such as resizing, cropping, and converting file formats. It can be useful for a webcomic site if you need to process and edit images before uploading them to the site. FileZilla, on the other hand, is used to transfer files between a local computer and a server. It is a popular FTP client that can be used to upload files to a web server. FileZilla would be useful for uploading webcomic images to a website or web server. The main advantage of ImageMagick is its ability to process and manipulate images, which can save time and effort when creating and uploading webcomics. The main advantage of FileZilla is its ease of use and reliability when uploading files to a server. In summary, ImageMagick is an image manipulation tool, while FileZilla is a file transfer tool, both of them can be useful for a webcomic site, but for different purposes. The choice will depend on the specific requirements of your webcomic site.
  17. @bernhard could you please add PHP 8 as dependency for the latest Version 2.1.0. Thank you. Was updating a website today that still runs on 7.4 and got composer errors because mpdf requires PHP>=8.0.
  18. Looks Awesome. Thank you for sharing. Will definitely have a look. As I understand it from the docs, every block is being wrapped inside a <div> element. I wonder if this would have negative impact on machine readability and therefore SEO since page markup is not really semantically structured anymore. Maybe I'm wrong, and it is semantically ok to have something like this? div section div article div section div article etc. I know that this is an issue with most page builders. They need that extra markup.
  19. Have you tried $page->products_codes->sort("parent.title")?
  20. To guard against execution of scripts inside vendor folder there seem to be 2 common approaches. move vendor outside webroot protect vendor folder with a .htaccess file I 'm just wondering if option 2 might be the better in our case because it doesn't involve changing core index.php Other CMS include a .htaccess inside vendor. Drupal for example does it like this with following content in vendor/.htaccess # Deny all requests from Apache 2.4+. <IfModule mod_authz_core.c> Require all denied </IfModule> # Deny all requests from Apache 2.0-2.2. <IfModule !mod_authz_core.c> Deny from all </IfModule> # Turn off all options we don't need. Options -Indexes -ExecCGI -Includes -MultiViews # Set the catch-all handler to prevent scripts from being executed. SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 <Files *> # Override the handler again if we're run later in the evaluation list. SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003 </Files> # If we know how to do it safely, disable the PHP engine entirely. <IfModule mod_php.c> php_flag engine off </IfModule> Other suggestions from SO for .htaccess are: Order allow,deny Deny from all Problem with this apporach seems to be that the .htaccess gets lost when you remove vendor and do a composer install for whatever reason. But this could be solved with composer scripts inside composer.json. For example a simple script that places an .htaccess file inside vendor after composer install is finished using the post-install-cmd event. In https://github.com/processwire/processwire/blob/master/composer.json after line 22 we could add , "scripts": { "post-install-cmd": "echo $'Order allow,deny\nDeny from all' > vendor/.htaccess" } Just tested this and it works. This is off topic but would you mind explaining why you are trying to avoid SMTP and what your preferred alternative is?
  21. Here's a good short comparison SSE vs polling: https://blog.axway.com/learning-center/apis/api-streaming/server-sent-events In short: use SSE!
  22. Have a look here https://stackoverflow.com/questions/53214116/intersectionobserver-callback-firing-immediately-on-page-load I made a codepen that does just that https://codepen.io/gebeer/pen/KKBMWzV?editors=1011 It uses getBoundingClientRect, though.
  23. Have a look at https://htmx.org/docs/#websockets-and-sse Server Sent Events might be a solution for you.
  24. You are making a good and important point here. My short tutorial serves as a proof of concept like stated in the introduction. For a full fledged implementation UX has to be taken in account. To improve upon my example, we can add browser history support by adding the hx-push-url attribute. So the hxAttributes part of my code would look like $hxAttributes = array(); $hxAttributes[] = 'hx-get="' . $nextPageUrl . '"'; $hxAttributes[] = 'hx-push-url="' . $nextPageUrl . '"'; $hxAttributes[] = 'hx-trigger="revealed"'; $hxAttributes[] = 'hx-swap="afterend"'; Now if a user follows a link to a single post and then returns to the overview via browser back button, they'd land on the same page they left off. To make this behaviour smarter and have the previous pages (batches) load on scrolling up, we could expand the whole logic by placing htmx attributes on the first post of every page (batch) with hx-swap="beforebegin". If a user came to /posts/page6 through a shared link, they could scroll up until they reach /posts/page1. IMHO you cannot compare htmx to jQuery since they serve completely different purposes. I think it leverages PW pagination capabilities quite well. I don't think there is a "best" solution for this use case. It depends very much on the context. It may fit well with some projects and might not be a good solution for others.
  25. Looks like https://processwire.com/modules/profields-table/ could be a good candidate for your use case.
×
×
  • Create New...