Jump to content

Torsten Baldes

Members
  • Posts

    188
  • Joined

  • Last visited

Everything posted by Torsten Baldes

  1. Hi bernhart ;-), thanks, that did the trick! Here's my code, if someone also needs to do this: wire()->addHookAfter('ProcessPageEdit::buildForm', function (HookEvent $e) { // skip the whole thing and return, if the user has not the proper role if (!wire('user')->hasRole('superuser') && !wire('user')->hasRole('useradmin')) return; $form = $e->return; $boxes = ['privacy', 'consent']; foreach ($boxes as $box) { $boxfield = $form->getChildByName($box); if($boxfield){ $boxfield->required = false; } } });
  2. Hi, I have a website with some users and admins who create and administrate these users. In their user profile is a checkbox which is set to required. When the admins create or edit an user they have to check this checkbox to be able to publish this user. But this checkbox should only be checked by the user itself. So I want to set this checkbox to "unrequired" when a user with a certain role is editing this profile. I tried to do this with the following hook (check for role not yet included), but I can't get it to work. wire()->addHookBefore('InputfieldCheckbox::render', function (HookEvent $event) { if ($event->object->name != 'consent') return; $field = $event->object; $field->required = false; $field->set('required', 0); }); It catches the right field but it doesn't set the field to unrequired. Is this hook too late in the chain or do I have to do this with another property or method? Thanks!
  3. Whooohaaa! Thanks! That was more then I expected! I will give it a try.
  4. Thanks, but I don't want to / can't use an external service and PW can already do all the resizing and cropping stuff. I just want access to these features outside from the template context.
  5. Hi, I'm building a small REST-API for my ProcessWire website to use the content outside in other apps. There are a lot of images and the apps will run on many different systems (mobile phones, tablets with iOS and android). To have the ability to always request the optimal image for each device width and screen density, I don't want to generate a fixed set of image sizes. Instead, it would be nice to request the resized image on the fly by sending the URL of the image with some parameters (width, height, crop) to the server and get my resized and cached image back. Similar to scripts like Timthumb or phpThumb, but with all the nice additions (e.g. focus point) from ProcessWire. The URL could look like this: https://mydomain.tld/resize/?url=/site/assets/files/1125/profile-image.jpg&width=1200&height=1200&crop=1 The response of this would be the image itself, resized to a square image, 1200x1200px How would I approach this? Is there something like this already available? Thanks!
  6. @thomasaull Thanks for this module! It seems to be a great starting point for building an API. I have 2 questions: 1. How would you approach a multilanguage API? My idea would be to add a query param to the api call (e.g. /api/posts/?lang=fr ) and switch the user language before getting the field values. Is there another/better solution? 2. I don't need it right now, but how would I implement a session authentification when accessing the api? Thanks!
  7. Thanks for all your suggestions! I thought it would be possible with just one query. Connect Page Fields seems like a good choice here (because I have no idea, how I would use RockFinder with the GraphQL module ? ) Thanks!
  8. Hi, I'm new to GraphQl, try to wrap my head around it and I couldn't find it in the docs or here in the forum. So here's my question: Is there a way to "reverse" find and list pages which reference a page? For example, I want to get a list of speakers with all the needed fields (name etc.) and their talks at conferences. The problem is, that I don't link the conferences on the speaker template, but reference the speakers on the conference template. { speaker { list { u_name u_forename u_vita } } } How can I output the conferences for every speaker, when I'm querying the speakers? Is this possible? Thanks!
  9. Hi, I'm building a site where users can edit and update their user profile in the admin area but are not allowed to see/edit any other part of the admin (e.g. pages). (Note: These profiles have a different template and a different parent than the normal users. see: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users) In these profiles, I want to use multilanguage fields. But if a user only has profile-edit permission, he can't save these fields. To do this, he needs page-edit and page-edit-lang permissions. These permissions also let him see the page tree, which he shouldn't see. Is there any way to have multilanguage fields in a profile without page-edit-permissions? Single language fields work fine and without issues. Thanks!
  10. Hi, I have a multilanguage (en, de) ProcessWire 3.0.111 installation and when I copy a page, only the second language in text fields (text & textarea) gets copied. The default language is always blank on the new page and in all repeaters on this page. I tried to recreate this issue on a fresh installation, but with no luck. There it worked like it should. What can I do to track down this error and fix it? Thanks!
  11. @renobird Is there a way to purge the activity log? I tried removing and readding templates, but the older log entries were still there. Thanks!
  12. repost of my comment from the blogpost: Great additions! Thank you! One question for $page->references(): If a page is referenced from a repeater or similar fields, does it return the repeater page or the the „for page“ (the page where the repeater is used)? Thanks!
  13. Thanks! I did just that. I changed the col types for x & y in the DB from int(11) to decimal(5,2) and replaced the (int) with (float) for x & y in the module files. I also modified the js to output float values. Seems to work!
  14. Thanks for this module! I plan to use it for a map with quite a bunch of pins. For some pins the limitation to only have integer percentage values is too strict and they get placed slightly shifted from the original position? Is there a way to have float/decimal values for the coordinates? e.g. 35.75 Thanks!
  15. Is there any new development regarding the chinese characters? Thanks!
  16. @adrian Sorry I just saw this. If it breaks something revert it. Seems to work for me.
  17. Hi, I'm using LoginRegister and SessionLoginThrottle (core module). If a user tries to login with wrong credentials SessionLoginThrottle steps in and prevents a brute force attack. This works fine for the backend login. When someone tries this on the frontend, it produces an exception with an "Internal server error" message. Is there a way to output the same messages from the backend also on the frontend or catch this error and show some other hint to the user? Thanks!
  18. thanks for your suggestion. unfortunately "admin_city1" has also no access to users with "admin_city2". so it doesn't matter if I change the order.
  19. Hi, I'm using IftRunner (https://github.com/ryancramerdesign/IftRunner) to update/change the roles of a user based on a selection in the user profile. Example: The field "location" has multiple cities (city1,city2,city3) and when the user changes this field from "city1" to "city2", he should get the role "admin_city2", which can access and edit users with the role "usergroup_city2". Unfortunately the api call "addRole" seems to check, if the current user has the permissions to assign this role. Since he has only the role "admin_city1", he can't change his role to "admin_city2". Is there a way to "force" the api to do this, even when the current user doesn't have the permissions? Thanks!
  20. Thanks for the hint, but I want to automate it and send these users an email to remind them. So I have to get them via the api.
  21. Hi, I was looking for something similar and found this thread. @ryan Is there meanwhile a better/other way to do this or is this still the way to go? My use case is the following: I create users and the users have to update their profiles with additional information. Now I want to find all users which didn't modify their profile. So I wanted to build a list of all users where the created and modified date is the same. Thanks!
  22. Thanks for the module! Is there a way to set the contents of this field via the processwire api? I'd like to import a large chunk of contacts and I'm using this fieldtype to store the phone numbers. Thanks!
  23. Hi, I'm using the form api to build my forms (like this: https://processwire.com/talk/topic/2089-create-simple-forms-using-api/) and today someone got a WireCSRFException which resulted in an Internal Server Error. Because of this, I have 2 questions: What could be the reason for this failed token check? How can I catch this error and display a message on my page (above/below the form)? The Internal Server Error page seems a little bit rude and irritating for the average user. Thanks!
  24. @FrauSchnatalie @renezschoch Das was René sagt. ??

×
×
  • Create New...