suntrop

Members
  • Content Count

    275
  • Joined

  • Last visited

Community Reputation

43 Excellent

1 Follower

About suntrop

  • Rank
    Sr. Member

Profile Information

  • Gender
    Not Telling
  • Location
    Germany, Cologne

Recent Profile Visitors

3,503 profile views
  1. suntrop

    Hi OLSA, thanks for your code. On the second look, I think this can work for me. But this one focuses on the posts again, not the groups. I think I found a fairly simple approach, but haven't tested thoroughly $i = 0; foreach ($user->groups() as $group) { $post = $group->find('template=posting, sort=-created, limit=1')->first(); $user->groups()->eq($i)->data('latest', $post->created); $i++; } // later I can foreach($user->groups()->sort('-latest') as $group) {…} I am just adding a new property 'latest' with the timestamp and can sort my groups by this new property later where I output my groups.
  2. suntrop

    This makes $posts only contain the posts. But I need a list of the groups. The webpage looks something like this at the end: See latest posts from … » GROUP #2 (with a Post from 2018-12-05) » GROUP #1 (with a Post from 2018-12-01) » GROUP #x (with …) » GROUP #y (with …) …
  3. Hi there! I'd like to sort some pages – kind of categorised blog posts. CMS: Blog - GROUP #1 - Cat A - Post 2018-12-01 - Post 2018-10-10 - Cat B - Post 2018-11-11 - Post 2018-05-05 - GROUP #2 - Cat C - Post 2018-12-05 - Post 2018-01-01 - GROUP … The user can select from different options to sort GROUP #1, GROUP #2, GROUP #n pages by date, title and … latest posts. If the user selects "Latest posts" it should show as: See latest posts from … » GROUP #2 (with a Post from 2018-12-05) » GROUP #1 (with a Post from 2018-12-01) » … Is this possible with a selector/PW's API? I guess it doesn't work like that, but perhaps I can utilise the newly added option to create a custom WireArray (https://processwire.com/blog/posts/processwire-3.0.117-core-updates/)? I think I have to loop the groups, find the latest post and create a new property with the timestamp.
  4. suntrop

    Well, you are right. Thanks for pointing me the right direction. Had the $user->of(false) on the wrong line and just needed to move it before setting the field value. Don't know, why this worked on the default login.
  5. Hi all I am using the login form $modules->get('LoginRegister')->execute() and have in /site/init.php $session->addHookAfter('loginSuccess', function($event) { // Update user's last login time $user = $event->arguments(0); $user->details->last_login = time(); $user->of(false); $user->save('details'); if(wire('page')->template == 'admin') return; wire('session')->redirect('/dashboard/'); exit(); }); But somehow, the last_login subfield doesn't update, if I use the Login/Register module login. However, it updates using "PW's default login". Any idea why? Seems to be the only reliable method to check if the user logged in successfully. The other one, afterLogin, runs for failed logins as well, as I can see.
  6. Ha didn't know this is possible. Have this working now with $ps = wire('pages')->find('template=board, (children.children.created>="24 hours ago"), (children.children.children.created>="24 hours ago"), (children.children.children.children.created>="24 hours ago")'); … perhaps I wasn't clear enough, I need some levels more. Anyhow, the above will work for me. Thanks Zeka!
  7. I want to find pages, which have sub sub pages created the last 24 hours. Those two selectors don't work … I guess, because I am looking for grand (grand) children, not direct children. $ps = wire('pages')->find('template=board, children=[created>="24 hours ago"]'); $ps = wire('pages')->find('template=board, children.created>="24 hours ago"'); Does children in this context mean only direct children, or any children, grand children etc.? Any idea how to get my pages? Home - BOARD A - - Cat 1 - - - Page (created 96 hours ago) - BOARD B - - Cat 1 - - Cat 2 - - - Page (created 12 hours ago) - - - Page - - Cat 2 - BOARD C - - Cat - - Cat - - - Page - - - - Page (created 5 hours ago) - - - Page Need to find BOARD B and BOARD C
  8. Thanks. Now it works here too. Don’t know what was wrong. I tested all sorts of combinations. Had it going in two steps, first finding all pages with the first param, and then finding amongst them the page with the second parameter. But with one selector it is much better Anyhow, thank you for testing.
  9. I need to find a page with two parameters which are contained within a text field. It is kind of a list of technical parameters. Content of a field looks like: 2 mm 80x110 cm 1310 g white or 1,5 mm 50x90 cm 1210 g black Mostly I am looking for the first two rows. I thought this one should work, but i doesn't: $result = $page->child('attributes^="2 mm", attributes%="80x110 cm"'); Both operators (^= and %=) work on its own, but not combined. Is this not translated to find the child page, that has "2 mm" on the beginning of the attributes field and also has "80x110 cm" in the attributes field?
  10. suntrop

    Reason found. It is one of my modules … I don't know why it didn't work when I disabled all modules. // Add hook for Email fields, to prevent two email fields share the same email address $this->addHookAfter("InputfieldEmail::processInput", $this, "validEmail"); protected function validEmail($event){ if ($event->wire('page')->rootParent->id != 2) return; $field = $event->object; if ($field->name == 'email') { $page = $this->modules->ProcessPageEdit->getPage(); $oldEmail = $page->get($field->name); $newEmail = $field->value; $existEmail = $this->wire('users')->get('id!=' . $page->id . ', email=' . $newEmail); if($existEmail && $existEmail->id > 0) { $field->value = $oldEmail; $field->error($this->_("Die E-Mail-Adresse $newEmail ist bereits für einen Kunden gespeichert")); } } } I had some trouble before, with this one (don't remember what exactly). I need this, to prevent users share the same email address. But the server error stays the same. Even without the code above, and I can save TD settings, I still get the error 500 if TB is enabled.
  11. suntrop

    Yes, used a Private Window
  12. suntrop

    I have (updated to) v4.13.6 on PW 3.0.98 with PHP 7.0.11. I disabled all my modules and still got the server error. Whenever I click the Save button I get redirected to /processwire/module/bookmarks/ nothing will be saved and the error message "ProcessWire: Unrecognized path" is displayed. TD is enabled and Output mode is set to Detect.
  13. suntrop

    It took some time, but I figured out here is something wrong with my TracyDebugger installation. When I remove the folder I see the PW exception. I just noticed I can’t save anything in the TD config. I get redirected to a Bookmark page in PW. I can’t uninstall it or disable it, same error. I‘ll try to figure out if there is any of my plugins causing the trouble.
  14. Sometimes I see a server error 500, instead of a PHP/PW error message. I don't know why and it makes it hard to figure out what is wrong. Here is an example from today. try { $return = wireRenderFile('partials/confirm', $vars); } catch (\Exception $e) { throw new WireException('Render Partial failed: ' . $e->getMessage()); } Error: I was using an old/missing function in the file partial/confirm.php. But why do I see a server error (500) and not a PHP error message or the exception? Is this something particular to my server config?
  15. Thanks! That sounds good and is what I was hoping for . I wasn't sure if there are any limits when it comes to the API features if I skip the module and just create a class. BTW … what do you mean by installability? Just being able to install something isn't worth anything on its own, is it? Do I miss something here?