Jump to content

suntrop

Members
  • Content Count

    279
  • 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,839 profile views
  1. This one has a strange outcome. For example … find('template=city, children.children.created<"14 days ago"'); Result: Hamburg Berlin Hannover Wiesbaden find('template=city, children.children.created>"14 days ago"'); Result: Hamburg Bremen find('template=city, children.children.created<"14 days ago", !children.children.created>"14 days ago"'); Result: Hamburg
  2. Hadn't luck with timestamp either. Changed it now to this, and it's working for me. Anyway, thanks for your answer! $remove = wire('pages')->find('template=city, children.children.created>"14 days ago"'); $cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->removeItems($remove);
  3. I was trying to get pages that have grand children older than 14 days, but not newer than 14 days. $cities = wire('pages')->find('template=city, !children.children.created>"14 days ago"'); $cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->not('template=city, children.children.created>"14 days ago"'); $cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->remove('template=city, children.children.created>"14 days ago"'); The first one is, I guess, not supported by PW (not to mention something like created!>time), but the last two should work in my option. The filter() doesn't work either here. Please note, that all city pages have grand children older than 14 days, so I can't just find('template=cities, children.children.created<"14 days ago"') because that includes those pages having grand children from yesterday for example.
  4. 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.
  5. 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 …) …
  6. 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.
  7. 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.
  8. 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.
  9. 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!
  10. 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
  11. 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.
  12. 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?
  13. 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.
  14. 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.
×
×
  • Create New...