Jump to content

Torsten Baldes

  • Content Count

  • Joined

  • Last visited

Community Reputation

49 Excellent

About Torsten Baldes

  • Rank
    Sr. Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

14,558 profile views
  1. I got the same issue as @androbey and his solution worked for me too.
  2. Hi and thanks for the module! Do you send every log to Logstash or is there a way to only send a few selected logs? Thanks!
  3. I like all of these features! 😉
  4. @sekru Did you found a solution for this? I've got a similar/the same problem, which i just discovered on a live site 😱. For me headlines get underlined with "=" or "-", when i truncate text. It seems like that in newer versions from ProcessWire (since 22 May) the markupToText function (https://github.com/processwire/processwire/blob/dev/wire/core/WireTextTools.php#L57), which is used by truncate when stripTags=true, got some new options like linksToUrls (your problem) and underlineHeadlines (my problem). Unfortunately it seems not possible to set these options via the truncate function. I think truncate should set these options to false. @ryan Ist this by intent? Is there a way to prevent this? Thanks!
  5. The sorting of these queries is not really important. The important thing for me is, that the results from $find1 are in front of $find2. It's like a lazy weighted search, where I first search the titles of the pages for a keyword/phrase ($find1) and then search the other fields (body etc.) for the same keyword (excluding the ids from $find1). The logic here is, that pages, which have the keyword in their title, are more relevant/important than the other results and should come first.
  6. @dragan @bernhard Yes adding works to get a "unified" PageArray with the right order, but the pagination for this remains empty. $unifiedMatches = $find1->add($find2)->find("limit=$limit"); $unifiedMatches->renderPager() returns nothing.
  7. Thanks, but I'm afraid this doesn't work with pagination. At first I created a new wirearray and added the others. This worked regarding maintaining the order, but got me problems with the pagination. Your approach would possibly work too, but I would have the same pagination trouble. 😕
  8. Hi, I have multiple $pages->find() operations which result in multiple page ids. e.g.: $find1: 8044|10045|3702|11067 $find2: 2004|5421|9392 Next i'm searching these ids to get a new WireArray, which i can limit and paginate: $unifiedMatches = $pages->find("id=$find1|$find2, limit=$limit"); This works all as intended. The problem is, that this new collection of pages doesn't maintain the order of the ids in the selector. They are sorted by their id. $unifiedMatches: 2004|3702|5421|8044|9392|10045|11067 Is there a way to get the pages in the $unifiedMatches result in the order of the selector input? $unifiedMatches: 8044|10045|3702|11067|2004|5421|9392 Thanks!
  9. Thanks! I just posted a feature request.
  10. Thanks for your help! For now I ended up with something like this: wire('user')->setTrackChanges(Wire::trackChangesOn | Wire::trackChangesValues); wire()->addHookAfter("Pages::saved", null, function($event){ $user = $event->arguments(0); if($user->template->name == 'user'){ $userfields = $user->template->fieldgroup; $excludeFields = ['pass', 'roles', 'language', 'admin_theme', 'schedulerSkip', 'cpf_added']; $changes = $event->arguments(1); // check if there are any changes, if it's not an InputfieldFileAjax (also triggers the hook), the user changed his own profile, if the changed user is not a superuser (could be any other role to exclude) if(count($changes) && !wire('input')->get->InputfieldFileAjax && wire('user')->id == $user->id && !$user->hasRole('superuser')){ $userfieldsArray = array(); foreach($userfields as $userfield){ $userfieldsArray[] = $userfield->name; } //remove unwanted fields $changes = array_diff($changes, $excludeFields); // order changed fields like template $changesSorted = array(); foreach ($userfieldsArray as $item) { if(in_array($item, $changes)){ $changesSorted[] = $changes[$item]; } } $changes = $changesSorted; unset($changesSorted); // probably not necessary // get the changes in a string $changedFields = ''; foreach($changes as $change){ $changedFields .= $userfields->get($change)->label . "\r\n"; } // compose the mail $subject = "Änderung im Nutzerprofil von »".$user->u_fullname."«"; $message = "Hallo,\r\n\r\n das Nutzerprofil von ".$user->u_fullname." wurde aktualisiert.\r\nFolgende Felder haben sich geändert:\r\n\r\n" ; $message .= $changedFields; $message .= "\r\n\r\n" ; $message .= "Klicken Sie hier, um das Profil zu bearbeiten: ".trim(wire('urls')->httpRoot, '/').$user->editUrl ; $message .= "\r\n\r\n\r\n"; $mailmessage = wire('mail')->new(); $mailmessage->to('mail@domain.tld')->from($user->email); $mailmessage->subject($subject)->body($message); $sent = $mailmessage->send(); } } }); I decided that it's not necessary to send the before and after values within the email. This could even be a privacy and/or security issue. Thanks again for your ideas and help!
  11. Hi, I'm building a site with user profiles, where the users can change and update their profile. For different reasons it's important that the person who oversees these users get's an email, when a user updates his profile. At best with all the values that changed and their value before. I tried to hook into User::changed and this kind of works, but it get's triggered for every field, that's changed. With each trigger the list of fields also get's longer, so that only the last run contains all the changed fields. This would mean, i would send multiple emails for one profile change. Is there a way to prevent this and get all changes at once in only one hook run? This is my code so far (in ready.php): wire('user')->setTrackChanges(Wire::trackChangesOn | Wire::trackChangesValues); wire()->addHookAfter("User::changed", null, function($event){ $user = $event->object; $changes = $user->getChanges(true); // output changes as log entry wire('log')->save('testchangelog', print_r($changes, true) ); // TODO: send mail }); Thanks!
  12. Most of the time other users/editors use this Field to "generate" a selection of posts/pages which are applicable for the topic of the current post. Something like "If you liked this post, then these posts could also be interesting to you".
  13. Hi, I'm using the core module FieldTypeSelector (like Lister) to be able to create custom lists of pages on my pages. e.g. show me pages with template=foo, somevalue=bar and someothervalue=foobar. Is there a way to use OR groups (https://processwire.com/docs/selectors/#or-groups) with FieldTypeSelector? This way I could build a list of pages which have somevalue=bar OR someothervalue=foobar As a selector this would look like this: template=foo, (somevalue=bar), (someothervalue=foobar) Is this possible? I know I could insert this as a _custom selector, but this would kind of defeat the purpose of FieldTypeSelector. Thanks!
  14. 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; } } });
  15. 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!
  • Create New...