Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/30/2022 in all areas

  1. This week we have ProcessWire 3.0.201 on the dev branch which includes a couple minor fixes but also a couple of useful additions: There are new "Tab" field visibility options available for any field in the page editor. This makes the field display in its own page editor tab. It saves you from having to create a new/separate Tab field just to wrap around an existing field to make it display in a tab. So far I've found it particularly useful with ProFields (Combo, Table, Textareas, RepeaterMatrix) as well as the core Repeater, FieldsetPage and Images fields. For instance, I have a Combo field labeled "SEO" that lets me edit browser_title, meta_description, canonical_url, etc., and now I can add that field to any template and pages using that template have their own "SEO" tab. Sure you could do this before by creating a separate tab field with an "SEO" label, but now it's a lot simpler/faster, as any field can now display as a tab on its own. Like with the other visibility modes, also included are options to make the tab load dynamically on click with ajax or make the value non-editable. You can also optionally specify a label for the tab independently of the field label. This is because usually you want tab labels to be very short (1 word is best) whereas field labels have no such need. Please note that this new Tab option is exclusive to the page editor, and in order to work the field must not already be in a tab. Also added this week is a new $page->getMultiple() method. This method works the same as the $page->get() method except that it lets you retrieve multiple page property/field values at once and returns them in an array. For example: $a = $page->getMultiple([ 'foo', 'bar', 'baz' ]); list($foo, $bar, $baz) = $a; It also accepts a CSV string: $a = $page->getMultiple('foo,bar,baz'); By default it returns a regular PHP array, suitable for using in list() like the first example. But if you want it to return an associative array instead, then specify true as the 2nd argument: $a = $page->getMultiple('foo,bar,baz', true); echo $a['foo']; echo $a['bar']; echo $a['baz']; I find this method useful in reducing the amount of code/lines necessary in many cases, and most often I use it in combination with a PHP list() call, i.e. list($title,$subtitle,$body) = $page->getMultiple('title,subtitle,body'); That's all for this week. Thanks for reading and have a great weekend!
    1 point
  2. remove() takes the key as argument, not the value. I'd wonder, if the WireArray is numerically indexed, would there be a way to use a selector to find the item to delete first?
    1 point
  3. Hi @LexSanchez made a PR to support TikTok embed, thanks for this great module!
    1 point
  4. Hi guys, 5 years later… for separating the date components from a date field, I found this solution. This works fine. <?php $d = strtotime($page->datefield); echo date('d', $d) . '<br>'; //e.g 8 echo date('F Y', $d); //e.g. November 2015 ?> But I want to germanize the output. I tried this: <?php setlocale(LC_ALL, 'de_DE.UTF-8'); $d = strftime("%d. %B %G", strtotime($veranstaltung->datefield)); echo date('%d.', $d) . '<br>'; echo date('%B', $d); ?> But I'm getting an error: A non well formed numeric value encountered In my config.php I have these lines: $config->timezone = 'Europe/Berlin'; setlocale(LC_ALL, 'de_DE.UTF-8'); I don't know, if these settings from the date field are correct
    1 point
  5. Thx @DaveP I'd prefer to get a better understanding of how to customize ckeditor to my needs rather than fixing/rewriting things afterwards ?
    1 point
  6. FWIW there is another option - Find/Replace Textformatter module. I have been using it for just this kind if thing recently and found it really useful.
    1 point
  7. I'd suggest you use the core Lazy Cron module to trigger loading the JSON. Note that, as described on https://processwire.com/docs/more/lazy-cron/, Lazy Cron hooks into ProcessPageView::finished() to avoid slow page loads.
    1 point
  8. You can use https://doc.nette.org/en/utils/validators#toc-isemail I think that should work? Or just copy the single method? https://github.com/nette/utils/blob/35f77d3cef633ea75c1a620f40211b1494bfe00b/src/Utils/Validators.php#L304-L319 $isEmail = function(string $value): bool { $atom = "[-a-z0-9!#$%&'*+/=?^_`{|}~]"; // RFC 5322 unquoted characters in local-part $alpha = "a-z\x80-\xFF"; // superset of IDN return (bool) preg_match(<<<XX (^ ("([ !#-[\\]-~]*|\\\\[ -~])+"|$atom+(\\.$atom+)*) # quoted or unquoted @ ([0-9$alpha]([-0-9$alpha]{0,61}[0-9$alpha])?\\.)+ # domain - RFC 1034 [$alpha]([-0-9$alpha]{0,17}[$alpha])? # top domain $)Dix XX, $value); }; db($isEmail("post@kirchlein-im-grünen.de")); // true
    1 point
  9. @wishbone I fully understand you as non coder as we all try to build things for non-coders, but you also already know that non-coders have also to do a minimum; It wasn't my intention to feel rude (please grab this beer ? ? ) , I was trying to find again a way to say that reading the doc is what could help here. I mean the FormBuilder one, or the tutorial I linked on my previous post. Anyway, back to to your issue. I read the old code you linked, and there is the full code. It works, and if you follow (read again ?) the whole thread lol, you will find the solution for the honeypot technique (page #2 I think posted by @kongondo). About security concerns, there is no breach in the code and can be used as is. But again, without reading the doc, you will eventually get security issues only when you will add more input to the form. I mean here, the $sanitizing technique which give you "control" on the submitted user data. Again, sorry to insist, the FormBuilder module is what you need as non-coder, as I think it doesn't require code to be written, or maybe one line to render the form (I can't confirm, I have to read the doc lol ? ) and give you all the security you will need to stay safe. Code: Try something with the form, and do not hesitate to ask further help here ? Please, believe me, I am speaking by experience, we, coders, are lazy as f***, you can't imagine how ? Edit: Sorry, I didn't paid attention to your third message, you could head to the Job forum to get more attention.
    1 point
  10. For publish/hide you will only need to setup access control accordingly in the role that the users will have. Settings can be disabled with RestrictTabView. I think this is the one that might require some css to display none, or look for a hook where you could edit this markup.
    1 point
  11. I usually hide some pages because the user has no business snooping around them. Put in ready.php: if(!$this->user->hasRole('superuser')){ /* hide pages on their ID: 1026 FormBuilder 1000 Search */ $wire->addHookAfter('Page(id=1026|1000)::listable', function($event) { $event->return = false; }); } You have ro refine the condition fo the user though... In case you have more users or have to do this dynamically you are better off with permissions or a module to do this.
    1 point
  12. Hi I know this is an old topic, but I was just searching for this. A default value for me is, as someone mentioned above, a pre-filled value that will be used if you don't replace it with anything. For instance, I have a field that asks for a "span" value for a box. If it is not filled in, I want it to default to 4. Now, I can easily achieve this in the template, but the problem is that the user cannot see that it defaults to 4 - so having the field pre-filled not only gives me a starting value, but also informs the user. Joss
    1 point
×
×
  • Create New...