Jump to content

BillH

Members
  • Content Count

    113
  • Joined

  • Last visited

  • Days Won

    1

BillH last won the day on February 23

BillH had the most liked content!

Community Reputation

66 Excellent

About BillH

  • Rank
    Sr. Member
  • Birthday 03/06/1962

Contact Methods

  • Website URL
    http://arkesis.co.uk

Profile Information

  • Gender
    Male
  • Location
    London, UK

Recent Profile Visitors

1,278 profile views
  1. 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!
  2. 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.
  3. 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.
  4. 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).
  5. 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; } });
  6. 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:
  7. 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; });
  8. When you add data to a field, the data is not saved to the database. This is the same as when you type the data into the CMS form (before you hit the save button). As you know, after changing the content of a field you can save either the whole record or just that field: $page->save(); // Or just the field $page->save("integer_field"); But the hook is after Pages::saveReady, so it always runs just before the page is saved to the database – for example, the hook will run after a user hits the Save button but before data is saved to the database. So if you use $page->save(), the data will be saved twice, which is unnecessary – though extra safe!
  9. It might also be a good idea or turn output formatting off. Then you probably wouldn't need to use $page->getUnformatted(), and it might be better when setting values. So: ... if($page->template == "relevant-template") { $page->of(false); ...
  10. I'd suggest hooking on Pages::saveReady. So, you could put something like this (not tested) in ready.php: $pages->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments('page'); if($page->template == "relevant-template") { $originalValue = $page->date_field; $newValue = date("oW", strtotime($originalValue)); // or whatever you need to do $page->set("integer_field", $newValue); } }); Note that if hooking on saveReady you don't need to save the field or page because the page is about to be saved.
  11. Are the tags in your HTML on separate lines? If so, Firefox will insert a space. <p> Firefox will add a space at the end of this. </p> <p>But not at the end of this.</p> I haven't noticed this happening in other browsers, though perhaps I've missed something. I have a memory that Firefox has done this for many years at least, but I'm not sure. Note that the Inspect tool in Firefox Web Developer Tools re-formats the HTML for easy reading, repositioning tags for many elements, and it removes spaces before tags in at least some cases (which is not helpful and a bit strange in my opinion!), so it's not good for debugging such things. The Page Source tool is more useful. I note that the heading "About ProcessWire" does actually have a space at the end in the HTML source. This could be for various reasons - such as a Text Formatter, or simply somebody typing a space!
  12. The Page Protector module makes setting up access to front-end pages easy, and it allows editors (rather than developers) to control access to particular pages – although my guess is this is a feature you won't need. However, the module is not necessary for controlling access, and preventing access to pages for users who aren't logged in is quite straightforward without it (see the links in the post I suggested earlier). I don't know if there'd be any issues integrating the module with SAML. So, it'd be worth considering whether your project would be easier either using or not using Page Protector.
  13. I've never used the SAML module (or SAML), and I don't know exactly what you're trying to achieve (the level of security you need and so on), so I can't say whether your proposed method is suitable. However, do you really need to use SAML for some reason? If not, it's likely that it will be easier if you use PW's user authentication. It's not difficult to work with and is properly secure.
  14. You'll find nearly the same question (if I understand you correctly) and useful answers to get you started (I've just added one!) here: For SAML, you might want to start with this module: https://processwire.com/modules/saml-auth/. And there's a post about it:
×
×
  • Create New...