Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. If you're interested in ironing this quirk out as well, here's one possible solution: https://www.media-division.com/correct-name-capitalization-in-php/ ๐Ÿ™‚
  3. $count_arr = []; foreach($page->my_repeater as $rep) { $name_normalized = ucwords(strtolower($rep->lastname . " " . $rep->firstname)); $count_arr[$name_normalized]++; } arsort($count_arr, \SORT_NUMERIC); $leaders = array_slice($count_arr, 0, 5); The caveats are names with prefixes, like Scottish McSomething, which will end up being Mcsomething, and that there's no sorting among names with equal vote count.
  4. @Edison Hey man, adding the brackets and semicolon did the trick. Now the date gets populated during the saving and I don't have to add the earlier code to the footer of the templates. However, this did not help much to have the month translated and it still shows the month on English for any of the languages. Will try to move the profile to my real host which uses linux so that I can be sure that setlocale is setup and working properly. Maybe there is no issue but just the local server is messing things up. Moving the site to my live host did not solve the issue. There has to be something else that is messing up the things. P.S. Double checked that the DateTime field has the date format for every language as well as that the setlocale is properly set for every language as: bg_BG.utf-8, ru_RU.UTF-8, fr_FR.utf-8 and C (last one for English) Strange enough, only the date translation is not working but all other translated strings do work.
  5. Yesterday
  6. Yes, the data has to be editable. It is real estate data, so things change (price, description, etc).
  7. @Edison Will try that once I get back to my place in a bit as I decided to step back from the problem and then hit it with fresh power and some caffeine ๐Ÿ™‚ With the page->save approach all my dates were properly populated, so step one is completed, however when I echoed the date, it still does not change with the language switch. Starting to think that the issue might be caused by not adding the language packs or some field settings I've missed...
  8. I've got a basic AJAX submission form set up for a poll โ€“ the user enters a first and last name or a person they'd like to nominate and upon submission it stores the first and last name, as well as IP address and timestamp within a repeater row. The user can only submit, using the same IP address, once within a 24 hour period (done by cross-checking their IP with entries in the repeater as well as the difference between timestamps). I now want to return a 'live top 5' โ€“ like a leaderboard โ€“ (taking all first and last name entries and doing a 'count'). This is where I'm stuck at the most efficient way to do this. Counts need to be case-insensitive (michael jordan and MICHAEL JORDAN and miCHAel joRdaN would total three, not one each) and then should, ideally, sentence-case the returned top 5 along with the count What do you think? Thanks in advance for any advice.
  9. Does the module need to read data back from the external database and display it in an interface for editing, or is PW only used for creating new data and inserting it into the database? Because if it's the latter you could still use Page Edit as the interface for data creation. You'd use a saveReady hook to get, prep and insert the data from the page into the external database, then clear out the page ready for new data. Maybe you'd add an extra submit button to Page Edit ("Send to database") so that the normal save buttons can be used to temporarily save data locally and only the "Send" button finally inserts and clears the data when the user is ready.
  10. I created an issue for what I specified above. https://github.com/processwire/processwire-issues/issues/933
  11. Hi @chrizz, personally I load all my custom classes through an autoloader called in config.php. For this purpose you can also consider ready.php. However If the custom class is associated only to a specific module (it will be used only when this module is installed) I think you may consider to load it from within the module itself in init() or ready().
  12. Okay, after more investigating I can only reproduce this on image fields inside a repeater that have been set to "Vertical list (verbose)". To be clear it doesn't happen on normal image fields, only those inside a repeater.
  13. @MilenKo, you need to add the round bracket and semicolon ad the end. The last line must be "});"
  14. @Edison - another error, but this time on the closing bracket
  15. Hello folks, Your voice can also be heard: https://hacks.mozilla.org/2019/07/mdn-web-developer-designer-survey/ "The survey results will be published on MDN Web Docs (MDN) as an annual report. In addition, weโ€™ll include a prioritized list of needs, with an analysis of priorities by geographic region."
  16. teppo


    Glad to hear that the error has disappeared ๐Ÿ™‚ The problem might've had something to do with your environment, but the resulting error is an interesting one. In this case something attempted to change current working directory into one that wasn't allowed, so PHP threw an exception โ€“ and since throwing exceptions from __toString() is not allowed, that resulted in fatal error instead. This seems like an unexpected result, so it might be worth investigating if it can be avoided, though I'm not sure if there's any sensible way around this. As long as __toString() does anything even remotely complicated, there's a risk of running into this issue.
  17. Hi @MilenKo, the function closing round parenthesis and semicolon were missing, I have edited it above. Please note I had no time to test it, it may be necessary to tune it
  18. @Edison The code returned an error: P.S. With a bit of more digging, I was able to populate the value of $page->creaded by inserting the following code to my news-inner template: <?php $page->of(false); // date_created is my custom DateTime field for storing the value // To avoid date changes every time I edit the page, a check if the field is empty is added if($page->date_created == '') $page->set('date_created', $page->created); $page->save(); ?> Now I will test for multilanguage support and if it works, will report back ๐Ÿ™‚
  19. Hi @MilenKo, you could try with an hook in ready.php. In this example Pages:saveReady is called right before the page is saved, so this can be used to fill some fields right before save will be executed. Assumption is that this is triggered when you are saving the page from within the Admin area. $wire->addHookBefore('Pages::saveReady', function($event) { $page = $event->arguments(0); if($page->hasField('date_created')) { $page->date_created = time(); } $event->arguments(0, $page); }); I quickly wrote it in the browser w/o testing Please note, this is more a date_modified as it will be overwritten at the next save, but you can easily make it a "true" date_created, with something like that: if(empty($page->date_created)) $page->date_created = time(); Sorry, of course I thought Linux-wise ... as you have a Windows server when you have sometime have look if php locales are installed.
  20. I have a module (autoload: true) which uses a custom class. If it would be only relevant for templates, _init.php would be the way to go but due to autoload functionality I need the class also to be availabel in the backend - this is where _init.php stops working. If the class is declared in config.php it works fine - but is this the recommended way or is there a better solution for this?
  21. Edit: Forget it. The error disappear. Hi Does anybody understand why this error? SeoMaestro 0.8.0 / PW 3.0.135 Fatal error: Method SeoMaestro\PageFieldValue::__toString() must not throw an exception, caught ErrorException: chdir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/vhosts/xxxxxx.com/:/tmp/) in /var/www/vhosts/grupopages.com/sites/xxxxxxx.com/wire/core/WireDebugInfo.php on line 0
  22. @Edison There are no stupid questions especially when someone is trying to help without knowing all the facts. Unfortunately, even though I have full access to my server, I can't check /etc/default/locale as I am on a Windows server using OSPanel as my webserver. To make my life easier and to learn something new, I've added a new field called: date_created and set it as DateTimeField. Now the only thing left is to figure it out how can I save the value of $page->created to that field and to test the translation there. As I've mentioned earlier, maybe the issue is that I did not install any of the language packs available but only created the languages and added my _strings.php for frontend translation. As the owner of the website would be a super user, he does not want to have his admin and modules translated. I've added this code to my template footer: /* turn of output formating so PW do not give an error when we change the value */ $page->of(false); $page->date_created = time(); /* save the date_created field */ $page->save('date_created'); /* turn on output formating so PW work as it should */ $page->of(true); but for some reason it does not want to populate the value of $page->created to the date_created field... P.S. Since I am working on a testing profile, I can mark the option "default to todays date" and it would start saving the date/time, however if this was a profile with hundreds of pages that should preserve their creation date then I will have to populate somehow the value of $page->created to my DateTime field..
  23. Hi @MilenKo, I may be wrong but it looks like it's returning a php default locale. It may sound like a stupid question, but are your languages locales installed on your server? If you have access to your server you should check the file /etc/default/locale. Running a sudo cat /etc/default/locale you get the list of installed locales. I am asking that as I recall I had first to install locales on the server before I could use them. The html language directive is normally used by the browser or search engines to classify the page by language, so should not be relevant for this issue. Anyway you may wish to set the proper lang using this code snippet where html is generated: <html lang='<?= wire('user')->language->code ?>'> EDIT: sorry too easy ... the above snippet works if you create the following hook in ready.php: // call it using $user->language->code or wire('user')->language->code or user()->language->code $wire->addHookProperty('Language::code', function(HookEvent $event) { $language = $event->object; $event->return = $language->name === 'default' ? 'en' : $language->name; });
  24. @Edison I echoed the setlocale and it does not change for the language showing this for all of them: LC_COLLATE=C;LC_CTYPE=English_United States.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C I just noticed that I have a lang="en" in my html opening tag. Could it be because of that?
  25. Hi @MilenKo, it's curious strftime is only showing the date in English, it looks like the locale is not switching. Can you test the following for each of your site languages: echo setlocale(LC_ALL, 0); // Will return current locale If locale is properly switching you should see the corresponding locale associated to each language. Regarding the datetime field I can try to put in place a small a tutorial.
  26. Thanks for sharing this, EyeDentify โ€“ nice and simple ๐Ÿ™‚ Just a little note before folks go implementing IP logging: IP addresses are considered personal data, and as such you should keep GDPR (and similar legislations) in mind. Here's SE question that covers the details related to logging IP addresses: https://law.stackexchange.com/questions/28603/how-to-satisfy-gdprs-consent-requirement-for-ip-logging. (The general consensus seems to be that you don't need to ask for permission before logging IP addresses, but there are other requirements you do need to keep in mind.)
  27. Hey Bernhard! Just a heads-up that I've moved this older RockMarkup thread to the Module/Plugin Development area. Please let me know if you'd rather prefer to have it merged with the module thread โ€“ though if we merge it, posts here will probably show up before the initial post in that thread, so it may look a bit weird ๐Ÿ™‚
  1. Load more activity
  • Create New...