Jump to content

theoretic

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by theoretic

  1. @da², sorry, forum says that I have no permission to see the content You've quoted ( Could You please copypaste it here?
  2. Hi friends! And thanks for ProcessWire! There's an inconvenience in ProcessWire file translation process which, I think, deserves a topic here. It's a common case to have same translatable phrases in different translatable files. Using a translation context (in fact, a separate file holding all that phrases) is also a common case, at least for me. Generally i call that context I18N_GLOBAL. So my typical translation may look like this: <?=__( 'Accept', I18N_GLOBAL )?> The problem is that ProcessWire translation interface is context-agnostic. If You have to translate multiple files containing the same 'Accept'-related piece of code, it will be always treated as not translated yet, even if I18N_GLOBAL file is already translated. Quite annoying, especially if You have lots of phrases to translate. So dear Santa, could You please make translation interface context-aware and to mark all the phrases (in all the files) which already have translation in my I18N_GLOBAL file as translated? Or maybe I missed something, and there's a possibility to tweak some settings and achieve this? Thanks in advance for any possible advice or idea )
  3. Hi friends! And thanks for Processwire! While supporting a 5-years-old Processwire project I found that there are both InnoDB and MyISAM tables there. Personally I think that InnoDB is better for Processwire. MyISAM tables came from some modules written years before. Since I like websites to be fast, I altered all MyISAM tables to InnoDB. At first glance, it was a good solution, website is running fast and smooth. Could there be caveats? Maybe I'm taking some implicit risks? I Would like to discuss this.
  4. @bernhard, thanks! Quite an elegant solution, works like a charm.
  5. Okay, thanks! Admin pages are handled in their normal way, have nothing specific to add here. As to the frontend, the form is ajax-submitted to an API endpoint written by myself.
  6. Hi friends! And thanks for Processwire! I have an interesting question. Couldn't find an answer myself. Let's suppose we have a hook of this kind: $wire->addHookAfter("Pages::saveReady", function($event) { $user = $event->arguments(0); //some manipulations with user data } This hook can be triggered both by frontend (there are some forms there allowing users to edit their profiles) and by backend (when superuser saves user page). I'd like this hook to have different behavior in these two cases. My first guess was like this: $wire->addHookAfter("Pages::saveReady", function($event) { $user = $event->arguments(0); $page = event->object; if( $page->template == 'admin' ): //some admin-specific manipulations with user data } No way! $page is always null, no matter how the hook was triggered. Any idea how to guess which page has triggered the hook? Thanks in advance for possible help 🙂
  7. Hi @AndreasWeinzierl! Got into same trouble. Fortunatelty, it can be fixed quite easily. Just uncomment //namespace ProcessWire; at the very beginning of the module. Have no guess why @kixe had commented it. Works fine after uncommenting, at least for me )
  8. Hi friends! And thanks for Processwire! I have an interesting question concerning selectors. Let's suppose we have an "inventory" template with "owner" repeater holding all users who owned this inventory. The last repeater item represents the current owner. Is there any possibility to select an inventory page by some data contained in its last owner repeater item? Some pseudocode to clarify what i want: //getting inventory recently owned by different users by currently owned by current user $myInventoryPage = $pages->get("template=inventory,owners(last).id={$user->id}"); Using owners.id is not an option here because the "owner" repeater may contain the current user in any position, not the last one. Thanks in advance for any idea!
  9. Hi friends! And thanks for Processwire! Maybe i'm missing something, but i have no idea how to select an (admin) page by the process it uses. It could look this: "template=admin,process=my_process_name" This could be a great help while using a perfect ProcessSettingsFactory module (many thanks to @Macrura!). That module allows to create admin settings pages, each holding a certain set of configurable data fields. Getting that fields is a piece of cake: $settings = $settingsFactory->getSettings('general'); //'general' is the name of admin page holding the settings $phone = $settings->phone; Works great when we need quite a limited number of settings. But when the things are getting bigger, it becomes quite reasonable to create a number of settings pages and to organize all the settings into a unified structure. Here's an example how it could be: //getting all settings pages $settingsPages = $pages->find("template=admin,process=ProcessSettingsFactory"); //creating the settings object $settings = (Object)[]; //putting all data from settings pages into $settings object foreach( $settingsPages as $settingsPage ){ $settingName = $settingsPage->name; //e.g. 'general' $settings->$settingName = $settingsFactory->getSettings($settingName); } //now we can use the $settings object echo "<a href=mailto:{$settings->general->email}>Mail us!</a>"; This approach definitely requires a process-specific selector. Guess that it could also be implemented at module level but having a specific selector for process could be useful in a large number of tasks. Will appreciate any idea )
  10. @Jan Romero, You're super cool! That extra slash in form action value resolves the problem. Thanks a lot!
  11. Hi friends! And thanks for Processwire! I've got a strange PW behavior which i cannot explain. Maybe i'm missing something. I have a form with method=post and action=action_page (different from page where the form resides). I'm trying to use post vars in the action_page's template. Both $_POST and $input->post() are empty. Deeper analysis shows that PW performs a http 301 redirect to action_page after the form is submitted, so all post vars are no longer available. How can i prevent PW from doing so? Did some simple tests to find the reason, i'm 95% sure that the redirect is triggered by PW. Thanks in advance for any advice!
  12. Hi everybody! And thanks for Processwire! I like PW hooks and use them in almost all of my projects. But it appears i'm missing some functionality. Some pseudocode to explain my wishlist: //somewhere in site/ready.php addHookClass('Page(template=my_template)::my_data', function($event) { ... } //somewhere in site/templates/my_template.php var_dump($page->my_data); //should output a multilevel array or nested objects $page->my_data->set('some_var',$some_value); //doesn't write to database $page->my_data->save(); //$page->save('my_data') is not applicable here because my_data is not a regular PW data field In fact i'm trying to create a solution for manipulating per-user settings (how to display some data on some pages etc.) but this approach may appear to be useful in different cases. Any suggestions are welcome!
  13. Just to clarify the situation. It appears that i've run into Firefox memory issues. I have many Firefox tabs and windows opened at the same time, and sometimes it may lead to strange effects concerning sessions and cookies. So it's not a Processwire-related issue. Hope this will be useful for someone.
  14. Hi guys! And thanks for Processwire! I got a strange issue concerning user system behavior. Maybe it's a bug in Processwire, maybe i'm missing something. I'm developing a site having 2 different user templates: the native user template and member template. The alternative user template setup has been done according to official tutorial. What's working fine: "Regular" users can log in and log out as intended Member users also can log in and log out as intended using $session->forceLogin($memberUser) and $session->logout() "Regular" users (all having superuser permissions) can access admin pages and use them Member users have their own set of permissions, they cannot access admin pages What's buggy: Both $session->forceLogin($memberUser) and $session->logout() have no effect on "regular" user sessions. Logging in/logging out regular users have no effect on member user sessions. Member users can only access their own personal pages with member template, trying to access other member pages gives 404. The only project-specific thing which could potentially lead to this behavior is the empty password field for any member user. They always log in using $session->forceLogin() and credentials obtained from external API. Tried to assign a password for one of member users; that user could log in/log out using admin page but the above-described bugs were still the same for him. Have no idea how to fix this, will appreciate any help. Thanks in advance! P.S. I'm using Processwire 3.0.201 in both dev (Windows) and test (Linux) environments.
  15. Thanks @matjasp! It's exactly what i've missed.
  16. Hi friends! And thanks for Processwire! I've found a... hmm, not a bug but rather missing feature. Let's imagine we have a field of type Page Reference. Due to some reasons (e.g. for having possibility to create new pages directly from inputfield) we assigned a Parent page to Selectable pages settings of our inputfield. Later we decide that we n o longer need that Parent page setting. And - voila! - there's no possibility to unset it. In fact, this impossibility may lead to errors like "A page does not have necessary parent" which may appear while populating our inputfield programmatically. At the moment, the only way to fix this is to edit the database manually and to delete the parent settings from 'data' column. Hope this will be fixed in later versions of Processwire. Thanks again!
  17. @Pixrael, good question! I thought that PW database uses InnoDB by default but it was wrong. Did an InnoDB migration without changing any code, the concurrent tests are experiencing the same troubles as before with MyISAM, but now there will be more space for experiments. Thanks!
  18. Hi friends! Many thanks for the brilliant Processwire! I have an interesting question concerning concurrent requests. I'm working on a PW-driven API which should pass some tests required by my client, including a so-called concurrent request test. The test harness generates a certain number of unique http requests and "fires" them in almost no time (they're received by webserver with time difference of the order of milliseconds). However far from real life use cases, this test is absolutely required by my client. Experiencing such a high (however short) load, PW reveals some weaknesses mainly concerning database interaction. Almost all concurrent requests should update a PW-driven numeric data field (in fact a database table). Concurrent requests try to increment/decrement its value, and after that a final check of the field value is performed. In most cases the final check fails. In-depth study shows that PW may receive new requests before the current request is processed, and this may lead to wrong final value. I tried some possible solutions: Wrapping field-changing operations in a database transaction. No success. Using mysql table lock. In my case this also didn't give a versatile result. Writing a lock mechanism denying any operation with data field until the previous request(s) are ended. Not versatile enough again. Organizing request queue. Maybe the best possible solution, but didn't try it yet. So what are your ideas in this case? Any possible approach is welcome ?
  19. Hello everybody! And thanks for Processwire! I have an interesting task which i couldn't resolve in the way i'd like. Hope someone will give a good advice ? So let's suppose we have pages with template called 'event'. We need an easy way to check whether a user can participate in this or that event. In such cases i'd like to write a hook of this kind: //somewhere in site/ready.php $wire->addHookProperty('User::canParticipateIn', function($event) { //deciding whether user can participate or not $event->return = $result; }); //somewhere in a template file if( $user->canParticipateIn ){ //displaying a form etc. } This generally works with simpler tasks. But in this particular case we need to pass an argument to our newly created hook function. This argument will be an event page instance. So our possible hook should change to something like pseudocode below: //somewhere in site/ready.php $wire->addHookProperty('User::canParticipateIn', function($event) use ($page) { //deciding whether user can participate or not $event->return = $result; }); //somewhere in a template file if( $user->canParticipateIn($eventPage) ){ //displaying a form etc. } Unfortunately this doesn't work. Processwire gives an error: So is there any way to pass an argument to a hook in this case? Thanks in advance for any possible answer!
  20. I think that due to almost-impossibility to change Processwire default language it's not necessary to explicitly name the language from which the text will be translated. It's enough to change all "Translate from English" phrases to just "Translate".
  21. Hello Robert! Thanks for a perfect module! I've made some changes to it (e.g. possibility to set the source language in module settings), how can i collaborate with You?
  22. 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.
  23. @Jan Romero, thanks a lot! Your patch resolves the problem. I think it deserves Ryan's attention and should be added to Processwire core.
  24. 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!
  25. 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!
×
×
  • Create New...