Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/11/2023 in all areas

  1. Progress report: I'm developing/maintaining all the sites in question, so decided to run the risk of latest DEV (3.0.222) and PHP 8.2 ! Only hiccups so far seem to be either a) namespace issues for an old site which I hadn't declared ProcessWire namespace stuff in the templates yet, and b) PHP 8.2 being less lenient (i.e. more strict!) about certains aspects of coding. For example, one of the older libraries I had installed was accidentally using curly braces to access array index - e.g. somearray{$foo}. And I had a few errors in my code here or there where for the OR conditional, I had only put a single vertical bar (which I guess earlier versions of PHP let slide ? So, yeah - so far so good. Thanks for the input everyone. Will report back when fully migrated and let you all know how it goes.
    2 points
  2. I'm using the VSCode snippets that RockMigrations comes with - you can use pw-createmodule to create a regular module and pw-processmodule to create a process module:
    2 points
  3. The new dev branch version 3.0.222 contains about 20 commits and 16 issue resolutions. In terms of new features, last week I mentioned some upgrades to WireHttp, and below are this week's additions: Multi-language month and day names The WireDateTime class (aka the $datetime API variable) has been updated to support multi-language month and day names. Now all month and days are translatable in the WireDateTime file (/wire/core/WireDateTime.php). So if you request any date in a format that uses month names or abbreviations, or day names or abbreviations, they now support multi-language, whether you requested it from the wireDate() function or the $datetime API variable. ProcessWire has long supported multi-language month and day names when using a PHP version prior to 8.1 and you've requested a strftime date format that uses them. But PHP 8.1 dropped the multi-language supporting strftime() function, without leaving a suitable replacement. PHP's IntlDateFormatter can't be relied upon since it's not always compiled with PHP. But as of PW 3.0.222, now we have a suitable replacement. Though it does require you to translate the 7 days and 12 months for file /wire/core/WireDateTime.php using ProcessWire's language translation tool. Note that unlike the previous strftime() solution, the new solution no longer requires you to use strftime() format codes and you can instead use regular date formats and they will be translated automatically. New conditional hooks that match by argument type Another new addition this week is support for conditional hooks that match by argument type. I think this is especially useful combined with ProcessWire's custom page class support. It enables you to make a hook apply only to methods containing arguments of a specific type. For instance, if you had a custom page class "ProductPage" for template "product" and you wanted to capture the "Pages::saved" event for pages of that type (ProductPage) you could do so like this: $wire->addHook('Pages::saved(<ProductPage>)', function($event) { $product = $event->arguments(0); /** @var ProductPage $product */ $event->message("ProductPage '$product->title' has been saved"); }); In addition to supporting class or interface names, you can also specify regular PHP types such as <array>, <string>, <int>, <object>, etc. For more details on this type of hook see the new Conditional hooks that match argument type section of the Hooks documentation. Thanks for reading and have a great weekend!
    2 points
  4. Hi, just ported over an old mail encryption/decryption routine using a Caesar cipher from some old projects to protect email addresses from spam bots, but show it normal for humans into a ProcessWire module. How it works: Enter email with double brackets where you want it [[example@domain.com]] in any CKEditor field Turns to <a href="javascript:cdc('dbfnrgmzfumx','SubjectX')">example<span class="hidden">(</span>@<span class="hidden">)</span>domain.com</a> A Javascript function decrypts the encrypted email on click Link is obfuscated from bots, but visible for humans (example@domain.com) Email placeholders are automatically detected via template _init.php file Placeholders gets replaced in template _main.php by wrapping $content around a PHP function Was super easy to implement with Processwire using the Intermediate / delayed output template strategy of the advanced default PW template and the great API. Super fun. P.S.: If someone is interested, I can post some code examples too.
    1 point
  5. Yes, they are up to date ? I mean... those snippets should also still work, but it's really a pain to keep them up to date. Even for fixing typos it's a lot of work, packaging everything into the bundle, adding all files and publishing it in the store. Whereas in RockMigrations it's just a git commit.
    1 point
  6. I just started playing around with this module, and so far it's really nice. There is just one thing that is a bit weird for me, as I don't really need that holiday entry. Is there a way to hide it? Sure, I could use showClosed=false, yet I'd like to list all days of the week, as it makes it way easier to read and compare. Another minor thing in regards to that holiday option that came up while playing around... would it be possible to somehow add a label to it and add up to 5 or more entries? For example, if I wanted to add Christmas Eve, the 1st and 2nd Christmas Day, New Year's Eve, and New Year's Day, That would be 5 days for which I would either need a date or a label, so everyone knows exactly what days are meant.
    1 point
  7. I guess PHP 8.3 coming out in autumn ? I know, but usually you do not enter opening times very often ?
    1 point
  8. Ah ok, thank you very much. I need to update my environment to PHP 8.2., too. PS: I love the module! (even if imho the time input field is a bit tricky to handle, but thats a browser thing)
    1 point
  9. Ok, I guess I found the issue...... PHP 8.2: The types null and false can now be used standalone. Take a look here https://www.php.net/manual/en/language.types.declarations.php I am running on PHP 8.2 and therefore I got no problems, so removing the return type on GitHub removes this error message on lower PHP versions. So this should work, because null is not standalone.? Anyway, I am wondering a little bit that no others discover this issue, because a lot of users are running lower PHP version than 8.2. Best regards Jürgen
    1 point
  10. Hello Juergen, thank you for you quick response. I'm running ProcessWire version 3.0.210 on PHP Version 8.0.28 As a workaround i tried to delete :null and now it works without any errors as far as i checked. But i guess, this should certainly not be the way to solve the problem. Can it maybe be influenced by other modules? I tried to install on my local as on my staging version and the error occurs on both sites. So possible this is influenced by something else? Thank you Matze
    1 point
  11. Hello @Matze First of all, thanks for reporting this issue. No it is not. I have tried to reproduce the issue, but (fortunately) the module works as expected on my site. I have done the complete installation process including creation of the OpeningHours input field and saving some values. The error that will be printed is also a little bit strange, because it comes from a default ProcessWire method and not from a method that I have written. This should be the method which leads to the error according to your provided error message on line 60: /** * @param Field $field * @return null User is not allowed to change this fieldtype to another * User is not allowed to change this fieldtype to another */ public function ___getCompatibleFieldtypes(Field $field):null { return null; } It seems that there was going something wrong during the installation process in this case. Could you please uninstall the module and reinstall it once more. It would be also interesting which PHP version do you use and which ProcessWire installation. Please let me know if a new install solves the problem. It is a little bit strange because no one has complained so far concerning problems during the installation process. Best regards
    1 point
  12. Hi, when trying to install it throws an error: Is this a known issue? Thanks.
    1 point
  13. Thx adrian, didn't know about those settings, sorry ?
    1 point
  14. Oh right, of course it only appears when you have switched to a different user. I can't think of many cases where I would want to stay as the currently selected user without having the ability to switch back to superuser but nice to have the option in case it is needed.
    1 point
  15. The End Session button should still be a thing. Basically it will kill the user switcher session and leave you logged in as the currently selected user with no option to change. As for a back to xxxx user, I am with Robin - there should really be no need for that, especially if you limit the available users via one of these settings. This lets you remove frontend only users etc from the list making it much more manageable to find your own superuser account to switch back to.
    1 point
  16. @LMD I think maybe this is what you want? This is saying to match template=repeater_gallery on the first argument to the method: $wire->addHook('Pages::saveReady(template=repeater_gallery)', function($event) { $page = $event->arguments(0); $event->message("Saving page with template=$page->template"); });
    1 point
  17. It's expected behavior as the selector in a conditional hook is applied to the event's object, which in this case is $pages, not the page that is about to be saved. You can convince PW to match the selector against the hook's arguments by stating the argument's number in front of the selector (there's an example in the docs towards the end of the conditional hooks section). In your case for the first argument, which contains the page: // match selector against $event->arguments(0) instead of $event->object: $this->addHookAfter('Pages(0:template=repeater_gallery)::saveReady', $this, 'myHook');
    1 point
  18. This is likely to be the problem. As @ngrmm mentioned, selector operators like > and < depend on the fieldtype used, so for a price you would want to use an integer field if you only need whole dollars, or a decimal field for dollars and cents (the decimal field is the better choice for futureproofing).
    1 point
  19. Monthly update: RockFrontend 3.2.2 is out ? Bug Fixes RockFrontend script tag in markup when not needed (25364be) add lattepanel again (had to temporarily remove it on previous release) Features add HumanDates library for better readable date ranges (1. Jan. 23 - 3. Jan. 23 ---> 1. - 3. Jan 23) don't load livereload in iframes and update minification only load RockFrontend.js if enabled
    1 point
  20. Yeahh. I - or better my first ProcessWire module EmailToEncryptedMailto - made it into issue #475 of the processwire weekly news. Thanks to Teppo for your promotion. Highly appreciated.
    1 point
  21. Time to write your very first module click ??
    1 point
  22. Coming to an IntelliJ IDE (like PHPStorm) near you soon. Live Templates or snippets provide a short way to write repeating code. You enter an abbrevitation and the editor completes the code for you. Here is one example when I want to setup a new module: phpstorm64_aT7Nj2gxSv.mp4 @bernhard Has snippets for VSCode in his great RockMigrations module also, be sure to check them out, if you use VSCode. As I use RockMigrations in every PW installation I also add snippets for migrations: phpstorm64_fAD9MoUJLE.mp4
    1 point
  23. Hi @fruid You have to turn on advanced mode by setting this in your config.php $config->advanced = true; Than on settings tab on that page you will be able to toggle 'system' checkbox
    1 point
  24. Thanks, very cool idea. The str_replace() isn't even necessary, if you use basename($ext = false). // Create $image->alt method wire()->addHookProperty('Pageimage::alt', function(HookEvent $event) { /* @var $image Pageimage */ $image = $event->object; $event->return = $image->description ?: $image->basename($ext = false); }); https://processwire.com/api/ref/pagefile/basename/
    1 point
×
×
  • Create New...