Jump to content


  • Content Count

  • 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,876 profile views
  1. When I check if the page has an image attached, I get the error PHP Warning: count(): Parameter must be an array or an object that implements Countable in But this should be the correct way if ( count(page()->images) ) { $heroimage = page()->images->first()->url; } elseif ( pages()->get('/')->images->first()->url ) { $heroimage = pages()->get('/')->images->first()->url; } I found some issues with this on GitHub, but it was fixed. Using PHP 7.3 and PW 148 (same issue before update).
  2. I've got an existing (pro field) textareas field containing two Page Reference fields. Do you know if subfields are supported using field templates? Those won't work $page->render('related', 'textareas/subfield'); $page->render->textareas; // will output both subfields
  3. Thanks for the link. Had not found the source. It seems the 'data-close' button will only listen for clicks if it is defined in 'data-buttons' as well. But all buttons living there will get the same design. Not that good, when Save and Cancel look the same, but it will work for now.
  4. In a custom process module I open a modal window containing a <form>. When I click the submit button, the modal stays open. I can't find a way, other the X from the title bar, to close the modal window. - How can close the modal, when the submit button was hit? - Or, how can I implement the buttonpane with the Save button like the PageTable module? - Or, at least, how can I include my own close button? That's how I open the modal: $field = wire('modules')->get('InputfieldButton'); $field->attr('id+name', 'status_update'); $field->attr('class', 'pw-modal pw-modal-small ui-button ui-widget ui-corner-all head_button_clone ui-state-default'); $field->attr('value', 'Update'); $field->attr('data-href', './status-update/?id=' . $op->id); $form->add($field); That's my save button $submit = $modules->get('InputfieldSubmit'); $submit->attr('data-close', 'close'); $submit->attr('value', 'Save'); $submit->attr('name', 'submit_dashboard_status_action'); $form->add($submit);
  5. 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
  6. 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);
  7. 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.
  8. 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.
  9. 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 …) …
  10. 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.
  11. 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.
  12. 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.
  13. 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!
  14. 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
  15. 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.
  • Create New...