Jump to content

interrobang

Members
  • Posts

    238
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by interrobang

  1. for interest I asked chatgpt if this can be done in a single selector. here is the answer:
     

    Quote

     

    Yes, you can combine these two queries into a single $pages->find() operation in ProcessWire. You can use a sub-selector to achieve this. Here's how you can do it:

    $searchterm = $input->urlSegment1;
    $myList = $pages->find("template=Template2, PRfield=(template=Template1, title={$searchterm})");

    This code will first find the page with template=Template1 and title={$searchterm}, then it will find all pages with template=Template2 that have a reference to the found page in the PRfield.

     

     

  2. 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. 

    • Like 4
  3. 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\"");

     

    • Like 2
  4. 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),
    ]);

     

  5. 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

    • Like 2
  6. 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.

    6 minutes ago, Andi said:

    So am I understanding correctly that this hook would also utf-normalize textarea fields for existing records, as long as user opened the page for editing and just hit save once?

    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.

    • Like 3
  7. 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);
    
    });

     

    • Like 4
  8. So far I haven't found a fully working regex. My test case is this. You you or anybody else finds a solution a PR is more than welcome.

    $test = "<h2>Fully URLs</h2>";
    $test .= "http://domain.com <br>";
    $test .= "http://domain.com/ <br>";
    $test .= "http://domain.com/dir <br>";
    $test .= "(http://domain.com/dir) <br>";
    $test .= "http://domain.com/dir/ <br>";
    $test .= "http://domain.com/dir/?a=1 <br>";
    $test .= "<h2>www. domains</h2>";
    $test .= "www.domain.com <br>";
    $test .= "www.domain.com/ <br>";
    $test .= "www.domain.com/dir <br>";
    $test .= "www.domain.com/dir/ <br>";
    $test .= "www.domain.com/dir/?a=1 <br>";
    $test .= "<h2>flourishlib Examples</h2>";
    $test .= "Example 1: www.example.com.<br>";
    $test .= "Example 2: https://example.com.<br>";
    $test .= "Example 3: john@example.com.<br>";
    $test .= "Example 4: ftp://john:password@example.com.<br>";
    $test .= "Example 5: www.example.co.uk.<br>";
    $test .= "Example 6: john@example.co.uk.<br>";
    $test .= 'Example 7: <a href="http://example.com">http://example.com</a>.';
    
    wireModules("TextformatterMakeLinks")->format($test);
    echo $test;

     

  9. 16 hours ago, gmclelland said:

    Love the module, but is there any way you could fix the trailing slash(/) on urls not being recognized?

    Unfortunately, I'm not very good with regex, but I still tried to solve the problem. Can you please give it a try if the result is better if you remove the \b in lines 52 and 53?

    Has anyone here with more regex experience an idea what problems could arise from this change?

  10. On 9.3.2018 at 11:28 AM, theo said:

    Hello

    Is there a way to share an editor.css for several CKEditor fields and make a difference for each? (talking about backend only)

    I tried sth like this:

    
    .Inputfield_textarea1 h1 {
      text-transform:uppercase;    
    }

    Meaning I want to uppercase h1 only for textarea1.

    But this doesn't work.

    I know I can write a separate css file for each CKEditor, but it would be easier this way.

    Thank you.

    You can add custom classes to the body of the ckeditor iframe. In the field settings (Input Tab) insert this in the "Custom Config Options" field:

    bodyClass: Inputfield_textarea1

    If you need more flexibility you can also hook create a hook in your /sites/init.php to add multiple classes to all of your ckeditor fields:

    wire()->addHookBefore('Field(inputfieldClass=InputfieldCKEditor)::getInputfield', function(HookEvent $event) {
        // do not show modified data on Field edit page
        if ($this->wire('process') != 'ProcessPageEdit') return;
    
        $field = $event->object;
        $page = $this->pages->get($this->input->get->id);
        $customOptions = $field->customOptions;
        $customOptions .= "\nbodyClass: template-{$page->template} page-{$page->id} field-{$field->name}";
        $field->customOptions = $customOptions;
    });

     

    • Like 3
    • Thanks 1
  11. Hi Nik,

    thanks, I am well :) Honestly I have not used my module myself for a long time, and I still have not looked into what has to be done to migrate this module to PW3 and its new image field. I plan to release a new version eventually, but can't say how long it will take. But seeing somebody still uses it at least motivates me to test it myself in PW3.

    Sorry, that I cant give you a more satisfying answer. I will post back here after testing.

     

  12. Sorry, I have not tested this module in any recent version, but I recommend using the dev version in the thumbnails branch, some minor issues might be fixed there: https://github.com/phlppschrr/ImageFocusArea/tree/thumbnails

    I have not looked into these new ajax features. Does anybody know of any thread here how to support ajax editing and loading for your own fields?

    Please continue to report any issues and improvement ideas here (or even better at github). 

    PS: Sorry, for being a bad module maintainer. I still have some plans with this module, but not enough time - too much customer work and a newborn baby at home.

    • Like 2
  13. I am currently using this field for the first time and I love it! Really a useful little time saver!

    One minor issue I found: I configured the folder path without a trailing slash. When editing a template i could see the files in the folder, but the field never saved the selected value. After adding a trailing slash to the foldername everything worked as expected. I did not see any warnings or errors on screen or in my logs.

    Another thing I still could not figure out is, how to use this field with showIf field dependencies. Is this even possible? I would like to show some other fields only if a certain file is selected. 

×
×
  • Create New...