Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by BillH

  1. Looks good. And the way you've used a "type" field in the blocks repeater has given me a really good idea for how to deal with a completely different issue on a site I'm developing!
  2. @rash I'd be interested to know if you do find other solutions.
  3. One thing I'd try is using Pages > Find to make the same selection, and then simplified version, and see if you get any results. If you have debug set to true in config.php, you can see the selector being used towards the bottom of the page. Another thing would be to try displaying the results of the find using the selector – and variations of it – on a page using print_r(). Or if you have Tracy Debugger installed (highly recommended!), return the result using bd(). BTW, it might be more efficient and a little easier to debug if you find and loop through the pages something like this: $batches = $pages->find("template=batch, batchdatestart<=today, batchdateend>=today"); foreach ($batches as $batch) ...
  4. As far as I can tell, the answer to your question is no, not directly. And it would be useful for me too if this could be done! If you include a text field in a repeater field, the site search doesn't seem to construct the correct selector. I tested this by selecting "View all" with debug turned on in config.php so that the selector appears at the bottom of the results on the Page Search page. For example, if (in addition to title) we add a field named text_in_repeater which is used in a repeater field named my_repeater, and if we search for "foobar", the relevant element of the selector would be: title|text_in_repeater%=foobar This doesn't work. To get the result we want, it would need to be: title|my_repeater.text_in_repeater%=foobar I don't know if this is something in PW that could be improved, or whether it must be this way for some reason. Or perhaps I'm missing something. Anyway, I can think of a couple of ways of dealing with this. The first would be to set up a field of type Cache, and include the fields you want to find in that. I haven't tested this for the purposes we're discussing, but my guess is that it'd work - but I could be wrong! If a Cache field doesn't work, another method would be to set up a text field, and then hook on Pages::saveReady (probably in ready.php) to add the searchable content you want to that field.
  5. Ah, I didn't notice which forum you'd posted this in! I'm pleased you find the answer.
  6. This doesn't help you much, but I can confirm that adding fields as you describe works fine for me. Is it possible that there's some problem with searching in the additional fields – for example, some hidden formatting that's interfering with the search? It might be worth setting things up to search in one of those fields only (and not in the title field) to see what happens. And have you checked that the default search operators (as defined in the module settings) are suitable?
  7. Hi, and welcome to the forums! Assuming you are using the Uikit admin theme (which you probably are), go to Modules > Core > AdminThemeUikit. Then in the Masthead + Navigation section, under User avatar select Image field: user_photo.
  8. You might find an answer in this discussion, which covers all the possibilities I could think of - and a couple more!
  9. My first guess would be that there is actually something in the job_titel field for those two entries that is causing the sorting error. Have you looked directly into the database fields themselves – using something like phpMyAdmin or Adminer (hosting companies often provide a tool in Control Panel or the like)? You'll find it's quite easy to navigate the PW database once you take a look at it. You may see something that you're not seeing using other methods.
  10. I don't know the cause of the trouble, though my first guess would be a timeout somewhere. Have you tried repeating the process with images of about the same size, and does the same error occur? And if it does, have you tried with smaller images? Have you checked the error logs (Setup > Logs)?
  11. I think that sorting by path simply isn't available using selectors. What are you trying to achieve? If it's to get the results into the same order as in the admin (which of course it may not be!), you probably want "sort=sort" (see "How to force pages to sort by their admin order with $pages->find()" on https://processwire.com/docs/selectors/).
  12. I wouldn't think there'd be an issue with different usernames - though I could be wrong. An error with accessing the database does sound like the right sort of thing, but I'd expect the consequences to be more wide-ranging and the errors to recur. My guess is that these errors were caused by something else. Have you turned on debugging in config.php ($config->debug=true;) and is anything interesting returned? And are you using the same version of PHP on both local and live servers?
  13. Have you tried checking the logs? If not, I'd suggest looking at Setup > Logs (or going directly to the log files at Site > Assets > Logs). If you can't identify anything, it might be worth posting an excerpt here.
  14. Take a look at the "Formatted value" section of the "Details" tab for your Icon field. You can see that the data can be returned in various forms. So, depending on your settings and the number of images, $icon->modified could return the modified value from an image – but it's not a modified value for the field itself. If you want to set a value for modified, you need to set it for a particular image. Note that if in your code you set output formatting to off (https://cheatsheet.processwire.com/page/built-in-methods-reference/page-setoutputformatting-true-false/) you will always get an array. And it will avoid trouble when setting values. So in your code I'd suggest: ... foreach($pp as $p) { $p->of(false); ...
  15. Your code is trying to set a modified time for the field, but you need to set it for each file contained in the field. So replace: $p->icon->set("modified",time()); with foreach($p->icon as $icon) { $icon->set("modified", time()); }
  16. Have you tried following the instructions at https://processwire.com/modules/process-menu-builder/how-to-use-menu-builder/#how-to-use-menu-builder? They're quite a long way down the page, so perhaps you missed them. You'll also find them in the README.md file of the module. And you might want to look at the support thread in the forums:
  17. Welcome to the forums! If you don't want to use inline CSS, would you be happy with including the CSS in the template file's head section? Something along the lines of: <style>.hero{background: url(<?=$page->hero_image->url?>) no-repeat;}</style> Or you could build the style line in a separate PHP file and include the file. I may be missing something, but I'm not sure that placing the PHP getting the image URL in a linked CSS file would be more scalable or cleaner than placing it in an included PHP file. And you could avoid having to wrestle with htaccess!
  18. Thanks @Robin S, useful to know.
  19. There's a really useful page https://stackoverflow.com/tags/timezone/info - though it'll make you realise you're opening something of a can of worms! I think, but I'm definitely not sure, that PHP uses the IANA/Olson Time Zone Database (linked on the above page). However, even if it does, I don't know how up to date PHPs list of time zones is. The Geolite2 database from MaxMind, at https://dev.maxmind.com/geoip/geoip2/geolite2/, is free and gives IANA time zone codes. This is another option: https://www.ip2location.com/free/olson-timezone. And there may well be quite a few other such sources out there. I don't know of any ready-made tool, but that doesn't mean there isn't one!
  20. Pleased it worked 🙂 Whether you set output formatting inside or outside the loop shouldn't affect the issue – though inside would waste a few processor cycles! I've done some tests, and the issue is a result of page->save() not working for custom image fields. Saving the image field (inside or outside the loop) is necessary to save the content of the image custom fields. Saving the page (inside or outside the loop) does nothing for the image custom fields. It seems to me that saving the page should work as it does with other fields, and I have reported this as an issue https://github.com/processwire/processwire-issues/issues/1334 However, there may be a good reason for it behaving as it does, and it has been pointed out on the issue page that the Table Profield behaves in the same way.
  21. I did this a few weeks ago and I got it to work. I seem to remember I had a certain amount of trouble saving the record, but I can't remember what exactly. However, the following code worked (I've simplified getting the text to add to the image fields). Note that I've done something a bit weird and saved both the field and then the page. This might have been an error (I was running a one-off process), or I might have found it was necessary for some reason I don't understand. It may just be that saving the field is what does the trick. Also, for reasons of my own, I used $record as a page variable, but I don't see why this would matter. Otherwise, I can't see any difference between this and your code. foreach($selectedRecords as $record) { if(count($record->article_images)) { $record->of(false); foreach($record->article_images as $image) { $image->photo_caption = "Some caption text"; $image->photo_credit = "Some credit text"; // First save $record->save('article_images'); } // Second save! $record->save(); } } Hope this helps, and I'd be interested if you find this works and can figure out what actually fixes the problem.
  22. Following on from what @teppo suggests, note that it's quite straightforward to write a script to import images into image fields on pages. There's lots of help on the forums for doing this (as a starting point, https://www.google.com/search?as_q=import+images&as_sitesearch=processwire.com). So, if you have a way of getting the image URLs into text fields (which it seems you have), you could write a script to run over the pages, loading the image(s) from the URL(s).
  23. I don't know of a way to do this with the template settings. However, if you want to the date to appear for only a particular template, you could add a check like this: wire()->addHookAfter('ProcessPageListRender::getPageLabel', function($event) { $page = $event->arguments('page'); // Check template if($page->template->name == 'relevant-template') { $modifiedFormatted = date("j.n.Y", $page->modified); $event->return = $event->return . ' ' . $modifiedFormatted; } });
  24. Welcome to the PW forums! The first thing I'd suggest, looking at the second line of the backtrace, is setting protectCSRF to false in config.php: $config->protectCSRF=false; If that doesn't get you in, take a look at https://processwire.com/docs/start/install/troubleshooting/ And then you may need to go back to working through posts: https://www.google.com/search?q="This+request+was+aborted+because+it+appears+to+be+forged"+site%3Aprocesswire.com%2Ftalk This one is a useful starting point:
  25. One approach would be to use a hook in ready.php, adapting the method described in this post: You'd probably end up with something like this (not tested): wire()->addHookAfter('ProcessPageListRender::getPageLabel', function($event) { $page = $event->arguments('page'); $modifiedFormatted = date("j.n.Y", $page->modified); $event->return = $event->return . ' ' . $modifiedFormatted; });
  • Create New...