Jump to content

BillH

Members
  • Posts

    221
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by BillH

  1. 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) ...

     

    • Like 1
  2. 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.

     

     

    • Like 1
  3. 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?

  4. 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.

    • Like 1
  5. 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.

     

     

     

    • Like 1
  6. 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)?

     

  7. 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?

  8. 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);
        ...
    
  9. 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!

  10. 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!

    • Like 1
  11. 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.

    • Like 2
  12. 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.

    • Like 1
  13. 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).

     

  14. 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;
    
    	}
    
    });

     

  15. 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:

     

  16. 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;
    
    });

     

    • Like 3
×
×
  • Create New...