Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/04/2020 in all areas

  1. Without much testing this hook works for me (in site/ready.php). But I think utf normalizing should be part of the core text sanitizer, so other texts (like image descriptions) are normalized too. function normalize_UTF_NFC($string) { if (function_exists('normalizer_normalize')) { if ( !normalizer_is_normalized($string)) { $string = normalizer_normalize($string); } } return $string; } $wire->addHookBefore('InputfieldTextarea::processInput, InputfieldText::processInput', function (HookEvent $event) { /** @var Inputfield $inputfield */ /** @var WireInputData $input */ /** @var Language $language */ $inputfield = $event->object; $input = $event->arguments(0); if ($this->languages && $this->languages->count > 1) { foreach ($this->languages as $language) { $input_var_name = $language->isDefault() ? $inputfield->name : "{$inputfield->name}__{$language->id}"; $input->set($input_var_name, normalize_UTF_NFC($input->$input_var_name)); } } else { $input_var_name = $inputfield->name; $input->set($input_var_name, normalize_UTF_NFC($input->$input_var_name)); } $event->arguments(0, $input); });
    4 points
  2. You can check if a variable is defined with isset. This will not throw an error even if the variable does not exist in the current scope. If you want to also check if the variable is not empty (falsy), you can use empty, which will also not throw an error if the the variable does not exist. // this will throw a warning if $order does not exist if ($order) {} // this will never throw a warning, and will be true if $order is defined, even if it's value is null if (isset($order)) {} // this will never throw a warning, and will be true if $order is defined AND a holds non-falsy value if (!empty($order)) {} As a side note, in your production environment you should configure PHP to not display any errors on the webpage, and instead log those to a logfile that only you have access to. To do this, change the following settings in your PHP.ini: display_errors = Off display_startup_errors = Off error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT log_errors = On error_log = /path/to/error.log
    4 points
  3. To be honest, I just googled a bit, I probably don't understand more of this than you 😉 Btw, Wordpress is discussing this now for 6 years: https://core.trac.wordpress.org/ticket/30130 Also, I don't know if this normalizer function is usually available or not – there are polyfills, but then all gets complicated. I am not sure if just saving is enough or if the fields need some changes tracked. Better test before re-saving 1000s of pages.
    3 points
  4. I understand 🙂. Look at it this way (as a friend put it), I am pretty much building a Shopify!
    3 points
  5. Haha ok then maybe it should also be mentioned that on both of my Linux machines none of this cr#p is any issue at all 🙂
    3 points
  6. Beware, a textformatter doesn't help with your search issue, as the texts in mysql are still the same and not normalized.
    2 points
  7. ¡EXACTLY! I'm already exhausted thinking it's being done by one person (?) lol
    2 points
  8. Haven't gotten to the coding part yet, but we had a longer team conference this morning and tried to narrow down this issue a little bit.. In the name of science, so to speak. We tried 4 people with 4 different setups, all copy/pasting to PW from the same PDF file, and those were the results: #1 macOS High Sierra 10.13.6 - Apple PDF Preview -> PW: Broken diacritics - Acrobat Reader -> PW: Broken diacritics - Google Drive (Browser) internal document viewer -> PW : Good diacritics #2 macOS Catalina 10.15.4 - Acrobat Reader -> PW: Good diacritics - Acrobat Reader -> Text Editor -> PW: Broken diacritics (no idea why..) - Google Drive (Browser) internal document viewer -> PW : Good diacritics #3 Windows 10 - No Problems with diacritics during copy/paste #4 Windows 7 - No Problems with diacritics during copy/paste So although I'll still have to implement a hook to deal with the existing records in the database, I think we've established a workflow for #1 to get clean data into the system right off the bat, or at least for the time being.
    2 points
  9. function convertYoutube($string) { return preg_replace( "/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", "<iframe src=\"//www.youtube.com/embed/$2\" allowfullscreen></iframe>", $string ); } Source: SO 😅
    2 points
  10. Ah, I just found the solution: the template of the older version has no namespace. After defining a namespace, the form works fine.
    2 points
  11. @JeevanisM Look like you use the wrong youtube URL. Try to see how is composed your URL and then be sure that you link youtube's video with the /embed endpoint as it allow cross origin request. Check : bad: https://www.youtube.com/watch?v=kSLhay7msTI gud: https://www.youtube.com/embed/kSLhay7msTI
    2 points
  12. After some tedious experiments, I finally managed to switch my site's default language from English to German both in frontend and backend. I am reliefed but not satisfied because it was a terrible hack: Starting with @mscore's SQL script, I added a condition to make sure that field texts are only swapped if a translation exists SET s1.data = s1.data123, s1.data123 = s2.data WHERE s1.pages_id = s2.pages_id AND s1.data1019 != ''; Especially important for backend field without translation, otherwise the backend text will get broken. Then, I added some lines in order to update the option names for FieldtypeOptions: UPDATE fieldtype_options s1, fieldtype_options s2 SET s1.title = s1.title123, s1.title123 = s2.title, s1.value = s1.value123, s1.value123 = s2.value WHERE s1.fields_id = s2.fields_id and s1.option_id = s2.option_id; The following statements are necessary for keeping the correct translation files for both languages (let 124 be the page id of the default language): update field_language_files set pages_id = 123 where pages_id = 124; update field_language_files_site set pages_id = 123 where pages_id = 124; Unfortunately, since translation files are stored in the assets, it is also necessary to swap the corresponding asset directory names: files/123 to files/124. The final step is changing the title of the new non-default language ("deutsch" to "english") and the language names respective. I can't understand why there's still no out-of-the-box solution for this use-case, which is IMHO not so unusual. I also would prefer a PW API solution like @gebeer's one, but I couldnt' find out how to iterate over really all stuff I need (including backend) ...
    2 points
  13. A new module that should suit your needs:
    2 points
  14. Thanks Moritzlost! That does just what I needed 🙂 (Y) You rock! 🙂
    1 point
  15. Always helps to know what you're looking for 🙂 https://modules.processwire.com/modules/textformatter-normalize-utf8/ Thanks for the pointers @interrobang, this is going to help a lot..
    1 point
  16. 1 point
  17. It's in AdminOnSteroids.php file 🙂 https://github.com/rolandtoth/AdminOnSteroids/blob/master/AdminOnSteroids.module#L2582
    1 point
  18. I'm sure you do. 🙂 I'm looking forward building headache-free ecommerce sites for my clients and enjoy it while I do. Until then, I'll politely decline those projects. 🙂
    1 point
  19. ...that Microsoft products are superior to Apple products 😉 😁. ...I'll crawl back under my rock now...
    1 point
  20. SnipWire provides sample templates to demonstrate how shop products could be rendered and is only thought as a starting point. Using the "Regular" site profile for displaying shop products within blog categories would not make sense as the blog articles are formatted very differently. You would need to write your own category template for listing shop products within categories.
    1 point
  21. Perfect timing. Thank you so much! 🙂
    1 point
  22. Hi, I have fixed with a small piece fo code as below : $url = "$videourl"; $shortUrlRegex = '/youtu.be\/([a-zA-Z0-9_]+)\??/i'; $longUrlRegex = '/youtube.com\/((?:embed)|(?:watch))((?:\?v\=)|(?:\/))(\w+)/i'; if (preg_match($longUrlRegex, $url, $matches)) { $youtube_id = $matches[count($matches) - 1]; } if (preg_match($shortUrlRegex, $url, $matches)) { $youtube_id = $matches[count($matches) - 1]; } $fullEmbedUrl = 'https://www.youtube.com/embed/' . $youtube_id ; and its working now ! the thread is closed !
    1 point
  23. Chart.js expects an array at datasets, even if you just use a single one. It'll work once you wrap that in brackets again.
    1 point
  24. @2hoch11 - Thanks. So the reason for the redirect is to take the page away from index.php so that it isn't seen as the home page. You simply need to change the source to index_php/{id}.
    1 point
  25. Thanks for the info. I pushed a fix (you don't have to reinstall).
    1 point
  26. Thanks, I should have tested that. Fixed now in v0.1.1 Good idea, I've added this in v0.1.1
    1 point
  27. Displays image tags overlaid on the thumbnail using customisable colours. This makes it easier to see which images have which tags without needing to open the edit pane for individual images or changing to the list view. Screenshot Usage Enable tags for one or more image fields. Install the Image Thumbnail Tags module. Optionally configure colours for any of your tags. https://github.com/Toutouwai/ImageThumbnailTags https://modules.processwire.com/modules/image-thumbnail-tags/
    1 point
  28. I hope that you all are having a good week and staying healthy. I’ve been very much focused on preparing a new ProcessWire-powered client’s website for launch, hopefully sometime next week. This is a site that’s already pretty well established with the search engines and such, so I’ve been going through all of the pre-launch QA in terms of optimization, SEO accessibility, mobile testing, getting the multi-language translators everything they need to translate, adding ProCache to the picture, and so on. For me this is one of the most fun parts of development, with relentless optimization and having it all come together… but also one of the most time intensive. This is where all the little details surface, things that need improvement become more apparent, and new ideas keep popping up. It’s also where lots of the bugs are discovered and fixed, and where I sometimes have to slap myself on the head for missing one thing or another, but then of course taking care of it. So that’s been most of this week, and I think likely at least half of next week too. But then it’s back to work on the core and modules, covering issue reports and more. I’ve actually been at work on some parts of the core and ProCache this week as well, but not to the point of finishing anything major. So you’ll see some updates on the core this week, and there’s also lots of stuff pending that’s not yet committed, and it’s all work in progress, so stuff to review later. With kids at home I’m still moving at a little slower pace than usual, but starting to get the hang of it, doing well and building momentum. While I don’t have much new to offer in this update, thanks for reading anyway, and I hope that you have a great weekend!
    1 point
  29. I think it's doable with AOS, check the FieldOverrides feature: https://github.com/rolandtoth/AdminOnSteroids/wiki/FieldOverrides
    1 point
  30. Hi all, Apologies for the very loud silence! I hope to elaborate more on this a bit later. However, rather than keep people guessing, I'll write something short. I have been working my fingers to the bone to release a beta by spring 2020. I suppose it hasn't gone unnoticed that I rarely post in the forums at large these days. This is because I am dedicating nearly all my time to Padloper. The plan was to start early beta testing in mid-April 2020. This was largely on track. Like many of us, maybe most of us in the forums, we have all been affected in one way or another by the current situation in the world. This has thrown a monkey wrench in the works. I have had to readjust how I work, albeit my productivity taking a hit. I wish I could properly 'guesstimate' how much delay this is going to cause but it will just be futile. On the other hand, I appreciate that you have been waiting for a relatively long time for this release. I want to reassure you that I am not just kicking the can down the road. Maybe I should have been showing you more screenshots of progress but currently, that would just eat further into my limited time. Thanks for reading, and hopefully, your patience. Cheers.
    1 point
×
×
  • Create New...