Jump to content

interrobang

Members
  • Posts

    238
  • Joined

  • Last visited

  • Days Won

    3

interrobang last won the day on May 4 2020

interrobang had the most liked content!

Profile Information

  • Gender
    Male
  • Location
    Munich, Germany

Recent Profile Visitors

9,214 profile views

interrobang's Achievements

Sr. Member

Sr. Member (5/6)

251

Reputation

8

Community Answers

  1. I just took a look at the source code and saw that in WireFileTools::render() all variables are added to data() of the rendered TemplateFile. You can get an array of the variables in your rendered file by $this->data(). Docs for data(): https://processwire.com/api/ref/wire-data/data/
  2. for interest I asked chatgpt if this can be done in a single selector. here is the answer:
  3. I have more and more customers complaining that they can't upload webp images. I understand that webp is not the ideal master image format, but neither is jpeg. The webp browser support is also so good now that it would not be necessary to generate jpeg/png versions from webp.
  4. I don't know a solution using TinyMCE but I used a textformatter in a similar case. I used TextformatterPstripper.
  5. Hi @ryan. The updates from FormBuilderFile sound great and I could very well use that in my current project. Is there any news when you will release this? Will the field also support drag and drop uploads? That would be even better ?
  6. Thank you both, unfortunatelly I can't test your suggestions right now, because the site is still using PW 3.0.150, which doesn't has these options. Upgrading PW to the latest dev broke my site, so I had to return to the old version for now. But I could solve my issue for now by quoting the value in the selector. After updating PW I will try your suggestions. pages()->get("template=$templateName, parent=$parent, title=\"$value\"");
  7. For an import script I need to match existing pages by page title, but some of the titles include a pipe. I cannot find a selector to get these pages. I have no idea what else to try. $title = "test | test"; // Non of these selectors get my existing page: pages()->get("template=edition, parent=3997, title=" . sanitizer()->selectorValue($title)); pages()->get("template=edition, parent=3997, title=$title"); pages()->get([ 'template' => 'edition', 'parent' => 3997, 'title=' => sanitizer()->text($title), ]);
  8. The more I think about it, I am sure we need a core solution. Even if we hook into every Inputfield::processInput method we know of, there will still be custom inputfields which we will miss. And if you populate your pages by api Inputfields are not even used and the hooks are never called. UTF8 normalization should be buried somewhere deep in the core: Probably every mysql query and all user input should be normalized automatically. Currently this is not possible with hooks alone as far as I know. Btw, I just found another lightweight library which provides a fallback function if normalizer_normalizer is not available: https://github.com/wikimedia/utfnormal
  9. Beware, a textformatter doesn't help with your search issue, as the texts in mysql are still the same and not normalized.
  10. 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.
  11. 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); });
  12. WTF?! Sorry, you are right, this is not useful.
  13. I think this would be a useful addition to the Sanitizer class. Something like this should do it: $dotfloat = rtrim(number_format($number,100,'.',''), '.0');
  14. Perfect! Thank you! I have merged your PR.
  15. Thank you! This looks good to me! If you make a PR I will merge and release a new version.
×
×
  • Create New...