Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

25 Excellent

About theoretic

  • Rank
    Full Member

Recent Profile Visitors

1,460 profile views
  1. Hi there! Got a strange WireMailSMTP behaviour. I'm sending emails via Gmail which works fine except one problem. Gmail browser client shows that emails like this: xxxxxxxxx@gmail.com 16:56 (23 минуты назад) кому: я X-Mailer: ProcessWire/WireMailSmtp Date: Tue, 24 Sep 2019 13:56:49 GMT MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="99e7bb5336c619adedcc743d03b1ec46" Message-ID: <20190924165649.0537.xxxxxxxxx@gmail.com> --99e7bb5336c619adedcc743d03b1ec46 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =D0=9F=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B8=D0=BB =D0=BD=D0=BE=D0=B2=D1= =8B=D0=B9 =D0=B7=D0=B0=D0=BA=D0=B0=D0=B7 . --99e7bb5336c619adedcc743d03b1ec46 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =D0=9F=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B8=D0=BB =D0=BD=D0=BE=D0=B2=D1= =8B=D0=B9 =D0=B7=D0=B0=D0=BA=D0=B0=D0=B7. It's obviously the quoted-printable decoding problem. Google also allows to download any message as .eml file, and here's a sample of what is inside such a file: X-Mailer: ProcessWire/WireMailSmtp Date: Tue, 24 Sep 2019 13:56:49 GMT MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="99e7bb5336c619adedcc743d03b1ec46" Message-ID: <20190924165649.0537.xxxxxxxx@gmail.com> --99e7bb5336c619adedcc743d03b1ec46 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =D0=9F=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B8=D0=BB =D0=BD=D0=BE=D0=B2=D1= =8B=D0=B9 =D0=B7=D0=B0=D0=BA=D0=B0=D0=B7 . --99e7bb5336c619adedcc743d03b1ec46 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =D0=9F=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B8=D0=BB =D0=BD=D0=BE=D0=B2=D1= =8B=D0=B9 =D0=B7=D0=B0=D0=BA=D0=B0=D0=B7. Both samples are parts of the same letter with some editing applied (real address changed, some inline css skipped etc.). Is there a way to make Gmail decode such letters in a correct way? Thanks in advance!
  2. Hi guys and girls! And thanks for Processwire! Just to give some help with Google account settings for WireMailSMTP. They are pretty well known... but Google appears to reject SMTP authentication from "non-trusted apps". There's however a solution which doesn't make Processwire "more secure" (from Google point of view) but unlocks the possibility of sending mails by WireMailSMTP using a Google account. You need to enable 2-factor authentication for Gmail account which You want to use with WireMailSMTP. You need to generate an "app password" different from Gmail account password. This "app password" should be used as SMTP password while setting WireMailSMTP up. Bingo! No more blocking. P.S. In my case, that Google blocking was occuring even if i tried to send a single letter per day. I'm not sending spam, just notifications for website owner/manager.
  3. Hi everyone! And thanks for Processwire! A small bug found in this great admin theme. It concerns the datepicker behavior. If we have two date fields one below another, the first field datepicker may slide below the input field of second field. The problem can be resolved by changing the AdminThemeBoss\uikit\dist\css\uikit.(color).min.css from: .pw .ui-datepicker#ui-datepicker-div { z-index:2 !important; background: ... to: .pw .ui-datepicker#ui-datepicker-div { background: ... Thanks again for this nice theme!
  4. @Zeka, thanks! The built-in selector array representation is good for relatively simple queries. But i couldn't find any example of correct select array syntax for cases like my_repeater = [ my_repeater_field1=value1, my_repeater_field2>value2, my_repeater_field3%=value3 ] I suppose that there's some array syntax for cases like this but i could'n find it.
  5. Hi there! And thanks for Processwire! It appears that i've found something interesting about PW selectors. They should only be strings! Here's an example of SQL-like syntax for selector: $my_complex_selector = " name='some name', parameter=123, other_parameter=[subparam>=subvalue] "; Trying to use this selector lead to a very buggy PW behaviour. It appears that newlines are treated in a very special manner by PW selector engine, preventing the newlined selectors from working as expected. I cannot imagine a situation when an unescaped newline could be a part of selector or selector value, so stripping newline symbols from selector could be a good idea for further PW development. And, currently, another good idea is to write complex selectors as PHP arrays: $my_complex_selector = [ "name=$name", "param1=$param1", ]; and to implode them into a single line before using find() and other functions which use selectors. Sorry if i wrote something trivial, but having this post already present at support forum could save me a couple of hours. Hope mine will save that tame for someone else 😉
  6. Hi everybody! And thanks for Processwire! The Leaflet Map module appears to have the same issue that the gmap-based Map Marker Map module. The map will not render if placed inside ajax-driven repeater item as one of its data fields because there's no leaflet map initialization after the ajax call. Here's a small fix to be added at the bottom of InputfieldLeafletMapMarker.js file: //A patch for displaying the map inside ajax repeater items $(".InputfieldHeader").on('click',function(event) { window.setTimeout(function(){ var $t = $(event.target).siblings('.InputfieldContent').find('.InputfieldLeafletMapMarkerMap'); InputfieldLeafletMapMarker.init($t.attr('id'), $t.attr('data-lat'), $t.attr('data-lng'), $t.attr('data-zoom'), $t.attr('data-type'), $t.attr('data-provider')); },500); }); }); The delay is rather arbitrary, 500 ms works for me.
  7. Thanks to all! Using SaveReady is more logical in my case because i need the recalculation of my field (marks) just before the page will be saved. Works like a charm! As to setAndSave, it will be more logical to use it in cases when there's no need to save the whole $page. However it's a very interesting approach also, thanks!
  8. Hello everybody! And thanks for Processwire! It appears that i have an interesting case concerning page fields resaving via modules. Let's suppose we're making a module which should run every time when a page is saved. Our module should calculate a value based on the values of some page fields, place this value to a dedicated field (in my case it's called 'mark') and save the page again. Below is the example of possible module code: public function init() { $this->pages->addHookAfter('save', $this, 'hookCalculateMarks'); } private function calculateMarks($page) { $page->of(false); //doing some calculations... //$page->save(); //will trigger endless loop calling hookCalculateMarks again and again! $page->of(true); $this->message("Marks calculated."); $this->calculated = true; } public function hookCalculateMarks($event) { $page = $event->arguments[0]; $this->calculateMarks($page); } The problem is that the commented page->save() triggers a save event which triggers the hookCalculateMarks which triggers page->save() which triggers the hookCalculateMarks which... oops, my mysql server has gone away. Tried to use a variable like $calculated... var $calculated = false; //some code skipped private function calculateMarks($page) { $page->of(false); //$page->save(); //will trigger endless loop calling hookCalculateMarks again and again! $page->of(true); $this->message("Marks calculated."); $this->calculated = true; } public function hookCalculateMarks($event) { $page = $event->arguments[0]; if( $this->calculated ) return; $this->calculateMarks($page); } ...but the problem is still present. Endless loop again. So what are the best practices for this case? What is the safe way to (re)save a field value afgter a page is saved? Thanks in advance!
  9. Hi everybody! It appears that there's a problem with the new version of General Settings 1.2.2 and PW 3.0.102 (without Lister Pro). Tried to install the General Settings 1.2.2 onto a fresh PW 3.0.102 via ModuleClassName, got an error of kind "GeneralSettings module is required". Also tried to download and install the General Settings 1.2.2 manually. Now the installation zip archive holds two modules: GeneralSettings.module and ProcessGeneralSettings.module . Tried to install GeneralSettings.module first, it was okay, but it appears that this module configuration has no effect. Tried to use $g_settings->my_setting_name in templates, no effect, $g_settings is NULL. Another glitch: there's no possibility to edit the settings via GUI at General Settings configuration page, could only trash/untrash and reorder them. The only way of adding/editing the settings is to edit the JSON on the same page. Finally went back to older ProcessGeneralSettings 1.1.4 which works like a charm. Thanks in advance for the possible debug and corrections!
  10. Hi there! And thanks for Processwire! Maybe i'm not very attentive but couldn't find any tutorial on creating custom fieldtype with custom inputfield. Would like to make one for selecting color(s) from predefined list of colors. The closest existing match is FieldtypeSelectOptions with InputfieldSelect but i need something different. There's a very good post from @Soma which is, however, insufficient to begin building my own fieldtype or at least to attach the existing inputfield to an existing field. Will appreciate any help. Thanks in advance!
  11. @Soma, great example, thanks! However it's not very clear how to assign this (or similarly developped) custom inputfield to existing data field. Thanks for possible clarifications!
  12. @Robin S, bravo! Cannot test it now (moved to a simper solution) but for sure Your proposal should work. The only thing i needed was to get the page holding both repeaters, and You did it using $page = $page->getForPage();
  13. @Robin S, thanks! Tried this, but still no result, the select options are empty howerver $page->variants is nonempty. P.S. Found a simpler solution which works without necessity of getting one repeater from another. The question however remains unresolved.
  14. Hello there! And thanks for Processwire. Got one more interesting question. One of my templates called goods has two repeaters. The first one is variants, each item containing possible sizes, colors and so on. The second one is available_variants, each item should contain a region and a variant which should be selectable from the list of variants. So the task is to get items of one repeater from inside the page reference field which is the part of another repeater, both repeater belonging to the same page. Processwire gives some options for retrieving selectable pages in this case. We can use: Parent. Not an option because we need dynamic parent being in fact the current page which contains both repeaters. Template. Not an option again because we need to select repeater items not only by template but also by page id which is dynamic. Custom find. Could be a solution but have no idea how to substitute the current page id into ID query. Selector string. It's almost what we need, but again i have no idea how to substitute something like "parent={$parent->id}" in this case. Custom PHP code. This needs to be placed inside site/ready.php and should contain a hook which finds pages using all the power of PW API. Think that the last option is the solution, but could not get the result i need. The simplest possible way seems to use $event->arguments('page')->variants. But it returns nothing. Tried different selectors like "template=repeater_variants, parent=".$event->arguments('page')->id , but still no result. Will be grateful for any help. Thanks in advance!
  15. Hi there! And thanks for Processwire! This is rather a question than a feature request, maybe there's a well known solution which i missed. So what about aggregation in selectors? Let's suppose we have a PW-powered shop where any product has a rating made by customers. Every time the user polls two data fields are updated: points and votes. The rating is calculated as this: $rating = $page->points / $page->votes; It was easy, yeah. But what about sorting products by their rating? Basically there are two ways of doing it: Creating one more field called rating and updating it after every vote. For sure it will work, but we have to create an extra data field which in fact stores data based on two another fields. Bad practice i think. Getting all products into array and applying a cutom sort function. Will work again, but this demands much more coding than using the native PW selectors. But how could it be done in the best possible way? Let's imagine this: $products = $page->children("sort=points/votes"); Or maybe this: function rating($a,$b){ return $a->points/$a->votes > $b->points/$b->votes; } $products = $page->children("sort=rating()"); Okay, let's go even deeper. Maybe we need "virtual" fields which are not stored in DB tables like other PW fields but represent the dynamically calculated values? $page->rating = function(){ return $page->points/$page->votes; } $products = $page->children("sort=rating"); Will be glad to see advice on the best practices. Thanks in advance!
  • Create New...