Jump to content

theoretic

Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by theoretic

  1. Hi all! As of end of May 2021 the situation has changed. PagePermissions.module included in Processwire 3.0.178 (and maybe in some of previous versions) has been updated, and @Jan Romero's patch is no longer actual. However you may need to manually create a new permission called user-view-all and apply it to guest role and maybe some other roles. After that guest users will have possibility to browse custom user profile pages.
  2. @Jan Romero, thanks a lot! Your patch resolves the problem. I think it deserves Ryan's attention and should be added to Processwire core.
  3. Hi there! And thanks for Processwire! I've got an interesting case concerning access to current user page. It appears that PW somehow limits access to the frontend page of current user. I'm speaking about a specific PW configuration. We have two kind of users: 'regular' users with native user template and member users with specific member template and specific members parent page (by the way, it's so cool that PW allows to use custom user templates and custom parent for certain user pages!). So a member with name Joe has a page with member template and url like /members/joe . The members template has some access limitations: only member users can see pages with member template. It works like a charm in most situations. For example, user Bill (who has member template and is logged in) can browse a page with url /members/ann which also is a member page with member template. And now, meet the glitch! The above-mentioned Bill cannot get to his own page /members/bill ! PW generates 404 page instead. I see no reason for this behavior. From my point of view any member should have access to any member page in this situation. What am i doing wrong? Any advice is welcome!
  4. Sorry guys. It appears i've run into an issue with the forum editor. I tried to edit my post around 10 times, it's still not visible. So i'll try to post it as plain text. Hi there! And thanks for Processwire! I have an interesting task which i cannot fulfill as i want. Maybe someone could help me please? Let's imagine a simple page structure of this kind: Category 1 + Item 1.1 + Item 1.2 Category 2 + Item 2.1 + Item 2.2 My task is to attach some items to more than one category, at least to show some items on different frontend category pages. With PW, it's a piece of cake. I've just created a field called Items (of type Page Reference) and attrached it to Category template. Since i have lots of items inside each category i preferred to use Page Autocomplete input for my Items field. The pages available for autocomplete are restricted by a very simple selector: template=item It works like a charm. But later i decided to make this autocomplete even smarter and to exclude current category children items from it. I tried to update my selector this way... template=item,parent!=(page) ...and oops, this broke my selector. My autocomplete founds nothing. Sorry, i had to replace the square braces by () because of forum limitations, i swear i'm using square brackets in real-life selector! What am i doing wrong? And is there any way to include current page info in autocomplete-related selectors? Thanks in advance!
  5. Hi there! And thanks for Processwire! I have an interesting task which i cannot fulfill as i want. Maybe someone could help me please? Let's imagine a simple page structure of this kind: Category 1 + Item 1.1 + Item 1.2 Category 2 + Item 2.1 + Item 2.2 My task is to attach some items to more than one category, at least to show some items on different frontend category pages. With PW, it's a piece of cake. I've just created a field called Items (of type Page Reference) and attrached it to Category template. Since i have lots of items inside each category i preferred to use Page Autocomplete input for my Items field. The pages available for autocomplete are restricted by a very simple selector: template=item It works like a charm. But later i decided to make this autocomplete even smarter and to exclude current category children items from it. I tried to update my selector this way... template=item,parent!=(page) ...and oops, this broke my selector. My autocomplete founds nothing. Sorry, i had to replace the square braces by () because of this forum limitations, i swear i'm using square brackets in real-life selector! What am i doing wrong? And is there any way to include current page info in autocomplete-related selectors? Thanks in advance!
  6. Hi there! And thanks for Processwire! It appears there's a possible bug in Processwire 3.0.170 concerning file and/or image inputfield. Creating such a field results in the following error: Fatal Error: Uncaught Error: Call to a member function get() on null The inputfield is created however. The closer look reveals a problem at line 60 in wire\modules\Fieldtype\FieldtypeFile\config.php: if(!$value) $value = $fieldtype->get('defaultFileExtensions'); Commenting this line removes the problem, but the newly created inputfield requires 'Allowed file extensions' config option to be set (which is rather expectable since i commented the above-cited line of code). Never faced this problem before, hope it can be resolved.
  7. It appears i've found a quick workaround for the problem. It's not a patch for PW core, just a methodology of writing hooks. Okay, here's a part of real hook which works perfectly on every site/admin pages having a certain inputfield except the admin page for that inputfield: ... $event->return = $event->arguments('page')->parents('template=products')->first()->find('template=cloth'); ... This hook fails on the inputfield admin page because first() is applied to nothing in this case. It's rather logical: the inputfield admin page has no parent with template=product ! So we need to split the above cited code into parts and to add some logic which will prevent the hook error on our inputfield admin page: ... //$realProductsPage works everywhere except the inputfield admin page, it fails there because admin page has no parent with template=products $realProductsPage = $event->arguments('page')->parents('template=products')->first(); //$stubProductsPage is used only on the inputfield admin page to prevent hook error $stubProductsPage = $event->pages->findOne('template=products'); $productsPage = $realProductsPage? : $stubProductsPage; $event->return = $productsPage->find('template=cloth'); ... It's far from being a perfect solution but it works.
  8. Hi everybody! And thanks for Processwire! There's a kind of bug or incorrect behavior associated with hooks for Page Reference fields. The Page Reference field stores references for PW page(s), sorry for being so banal. This kind of field needs some rules to fetch PW pages which will be available as content of inputfield. There are some possibilities to fetch that pages: by choosing their parent by choosing their template by custom find procedure having a nice user interface by PW selector string by custom PHP code Let's now focus on the last 5th option. In this case we should add some PHP code to /site/ready.php . Just an example from PW docs: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'cloth') { $event->return = $event->pages->find('your selector here'); } }); Up to this point, the things are simple and easy. But what if we will try something more complex? ... $event->return = $event->arguments('page')->parents('template=product')->first()->findOne('name=clothes,include=all')->children('template=cloth'); ... It's an excerpt from my real hook. I tested it both outside of the hook and inside it, it works (fetches the pages i need). But when i try so edit and/or to save my Page Reference field which uses that hook, i get an error of this kind: Fatal Error: Uncaught Error: Call to a member function find() on bool One more time: the above-cited piece of php code is correct. It populates my inputfield with the desired page references, the pages having that pagefield can be saved, fetched and so on. The only problem is that fatal error during save/edit of pagefield itself. I can suppose that this error takes place because the above-cited custom php code deals with some parent page(s). It works when the inputfield is used by non-admin PW page having correct parent(s) expected by cutom php code, but fails when we're trying to work with the admin PW page representing this inputfield itself. If so, we can consider a kind of "sandbox" for custom php code of this kind. Ideally, it shouldn't give us a fatal error even if it's incorrect. It should better throw an exception and output a warning, still giving us possibility to edit/save the inputfield admin page. Any ideas are welcome. Thanks in advance!
  9. Hi guys and ladies! And thanks for Processwire! It appears i've got an interesting issue concerning the template-settings-based PW redirects dealing with access control. Any PW template has some access control options i.e. "Login redirect URL or page ID to render". If this option is used for a page having a template with this option filled, a redirect will occur if user is not logged in and/or has insufficient access rights. I like to hook PW events. In one of my current projects i decided to write an addHookBefore('Session::redirect', ...) which should store the page we are being redirected from. With "regular" redirects like $session->redirect('/somewhere/') this hook works like a charm. But it was strange to see that it doesn't work with the template-settings-based redirect. I'm too dumb to dive deep inside PW and to examine the whole PW session mechanism. But it could be rather logical if ANY redirect ( no matter template-settings-based or using $session->redirect() ) could be hooked in the same manner. Okay okay i can forget about template-settings-based redirect and write my own. Just a couple of lines of code, and it works. But it's less elegant than hooking the template-settings-based redirects. So am i missing something? It this behavior a bug, or is it intended by PW team? Thanks in advance for any comment!
  10. P.S. It appears that the problem exists in Firefox only. Vivaldi renders such pages nice and smooth.
  11. Hi guys and ladies! And thanks for Processwire! It appears i've found a very specific case of template rendering behaviour. The steps to reproduce this: Enable markup regions in site/config.php: $config->useMarkupRegions = true; Let's suppose we have a data file templates/data.php with the content like this: <? return ['name'=>'value']; ?> This file is included into a template file default.php in the following way: <? //getting data from external file $data = include 'data.php'; //the rest of template logic and output ?> <html> <?=$data['name']?> </html> In this case the pages with default.php template are being rendered in a very strange way (at least in fresh Firefox). A flash of unstyled content, followed by repaint and rendering of styled content. It's very likely that the "return - include" construction causes some output before all the page html is fully prepared. It's easy to "fix" this behaviour: <? //inisializing $data in-place $data = ['name'=>'value']; //the rest of template logic and output ?> <html> <?=$data['name']?> </html> I like that "include-return" code approach and use it in many of my projects, and it was always giving no problem with page rendering. With the markup regions turned on, it becomes a problem. Are there any ideas how to use both "include-return" and markup regions together with no rendering trouble? And what could cause that trouble? Thanks in advance!
  12. For me it's still showing 3.0.153. Tried it using different browsers so it's definitely not the caching issue. Maybe it's because i'm in Russia? 😉
  13. @zoeck , thanks! It's a problem with the caption of download button. It says 3.0.153 but in fact it triggers the download of 3.0.155. Only the caption should be changed!
  14. Hi everybody! And thanks for Processwire! Guess many of us have noted the strange fact that there's a post about new Processwire 3.0.154 - 3.0.155 dev branches full of interesting new features but they still are not available for download. At the moment i'm writing this post the last available dev is 3.0.153 . For sure i don't want to force core develpers to make new branches available, it's just to clarify the situation. Dear devs, when could we expect the last dev branches to be available for download? Thanks in advance!
  15. Hi everyone! And thanks for Processwire! It appears i've found a bug related to translation of template files. I'm developing a website under Windows and publish it under Linux. When i try to add some translations to a template file in production environment (under Linux) this thing happens: File does not exist: /site\templates\product.php (translation file not needed? textdomain: site--templates--product-php) Under Windows i have no such problem. It's obvious that there's a problem with directory separator. It's a backslash ( \ ) under Windows and normal slash ( / ) under Linux. Have no idea how to make PW recognize this situation which makes impossible to translate templates in production environment. Thanks in advance for any possible help!
  16. 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!
  17. 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.
  18. 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!
  19. @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.
  20. 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 😉
  21. 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.
  22. 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!
  23. 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!
  24. 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!
  25. 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!
×
×
  • Create New...