Jump to content

dps123

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by dps123

  1. I have a small issue with my $pages->find query. My pages have a repeater field that is a checkbox. I'm trying to sort the results so that I get pages where at least one of the repeaters has the checkbox field checked. What I'm doing currently is: $my_pages = $pages->find("sort=-my_repeater.my_checkbox_field"); So I'm sorting high to low, i.e. checked before not checked. The issue is that it only appears to take into account the checked status of the first repeater item. If the second, third etc is checked, the page is not appearing at the top of the results. I'm guessing there must be an easy way to check all items in the repeater?
  2. Unfortunately not; that will give me checked items first. I'm just looking at this: https://processwire.com/talk/topic/3571-sorting-page-array-containing-pages-without-the-sort-field/, as that might be more like what I need.
  3. I can see there is an issue when I'm trying to sort pages by the repeater value. So when I'm doing sort=my_repeater.my_checkbox and wanting an order of 0 to 1, if there are no repeater items on a page, they are appearing first in my list. Can I do something for that?
  4. Any idea why this doesn't work: $user_image->url but this does: $user_image->url.$user_image when I'm setting that as my img src.
  5. Oh, I see. So my sort should be working. Let me take a look and possibly post another question!
  6. Thanks a squillion, I'll take a look.
  7. I'm trying to sort a $pages->find result by a checkbox value. sort=my_repeater.my_checkbox The idea is that I get pages with the checkbox unticked before pages with the checkbox ticked, i.e. 0 to 1. Because I haven't given my checkbox fields a name, they are using the field name. I can see in PW that the checkboxes are labelled my_checkbox_repeater123456 So I think my sort is not working. Is there a way around this?
  8. Can someone please show me what I'm doing wrong here. I've got a form for users to update their profile image. The image field is called 'profile-image'. I'm then using the API to update the image: if($_FILES['profile-image']) { $new_image = strtolower($sanitizer->name($_FILES['profile-image']['name'])); $user->of(false); // remove existing image $user->user_image->removeAll(); // add new image $user->user_image->add($new_image); // save the page $user->save(); $user->of(true); } The user_image field is set to 'Automatic' with a max files of 1. If I look at the user in ProcessWire, the image field says 'File cannot be displayed'.
  9. Yes, there's a 'comment_created_at' field on the comments. I tried that but it didn't affect the results.
  10. Any idea how I can sort newest to oldest? Changing to -created doesn't seem to work. $pages->find($commentsSelector . ', sort=-created, limit=10');
  11. Sorry, one question - what exactly are we doing here with 'afterjohn'? "afterjohn=(template=comment...
  12. Thanks LK, I'll give it a go when I get a mo. The support on this site is unbelievable. You really should charge people for this.
  13. Thanks guys! I hadn't realised just how complicated this was. LostKobrakai - will that method work with page numbers?
  14. So, here I am, working at the weekend again to get this site done. I'm hoping someone can help me get over this hurdle. I'll try to explain it as best as I can. I have notes pages using a template 'note'. Children of those pages are comments, using a template 'comment'. When a comment is posted, their username is recorded in the field comment_username attached to the comment template. There is one particularly important commenter. Let's call him John. What I need to do is select new comments where at least one of the comments before that was from John. I'm trying all kinds of crazy $pages->find things, but going around in circles!
  15. A client of mine is having an issue whereby Processwire is not remembering their logged in status. As part of the site, they are sent an email telling them there has been an update on the site. When they click the link, Processwire determines that they are not logged in and sends them to the log in page. When they log in, they get sent to the home page, rather than the link they clicked in the email. Does Processwire not create a session cookie? It seems fine for me - I can visit /processwire hours later and it remembers me. Also, if the user has purposely logged out, is there a way to remember the requested URL and redirect to it once the user has logged in?
  16. I thought just after I posted it could be the field type. It is a text field, so that's obviously the problem. Thanks for confirming
  17. I'm building up a selector for $pages->find, for example: template=horse, h_age=5, h_sex=gelding, sort=h_name If I change this to template=horse, h_age>5, h_sex=gelding, sort=h_name I'm getting: Error: Exception: Unimplemented operator in DatabaseQuerySelectFulltext::match() So it doesn't like the '>' for some reason. But I can see that that is a valid operator on https://processwire.com/api/selectors.
  18. I see, thanks. I'll look into the MarkupPagerNav.
  19. I have a custom pager on my page which has a select menu for selecting which page you want to go to. Each option in the select menu looks something like this: <option value="<?= $page->url.'page5'; ?><?= $_SERVER['QUERY_STRING']; ?>">5</option> So what I'm expecting is a URL like: /members/notes/page5/?horse=Horse+Name&category=5&from_date=01.04.2016&to_date=15.04.2016 But $_SERVER['QUERY_STRING'] is giving me this, which obviously isn't working when I append it $page->url. it=members/notes/&horse=Horse+Name&category=5&from_date=01.04.2016&to_date=15.04.2016 Has anyone else had this issue or know how I can get around it?
  20. Hi, just wondering if there is a neat way to get all possible values stored for a particular field. I realise I could do this with PHP and MySQL by querying the relevant field_my_field table, but wondered if there was a better way.
  21. Not sure what you mean by 'especially as the part is missing, where you get the value of the input field and save it to your variable.' This is where I'm grabbing the value of the note_page_id form field and assigning it to the note_page_id variable: var dataString = 'comment='+comment+'&note_page_id='+note_page_id.value; It works now that I've specified I want the value, but strange that I don't have to do the same with the comment variable, nor any others that I've used before.
  22. Whilst I've got your attention If I've got a variable $var = 'my_field'; Can I then use that in the API to specify a page field when setting it's value: $p->$var = 'something';
  23. Have just found that if I change my data string to: var dataString = 'comment='+comment+'&note_page_id='+note_page_id.value; the note_page_id is the correct value. But I don't normally have to do that. It normally just returns the value from the input name variable.
×
×
  • Create New...