Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by BillH

  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:
  15. Depending on how complex your needs are and the project's budget, there's also the Login Register Pro (paid for) module https://processwire.com/store/login-register-pro/.
  16. If you haven't discovered it already, the parent() function (https://processwire.com/api/ref/page/parent/) used with a selector can be useful for checking if a page has a particular parent - at any level, not just a parent immediately above it. It returns a null page (id = 0) if the page doesn't have a parent that matches the selector. For example, if you want to check if a page is a child of a page with id = 123: if ($page->parent("id=123")->id != 0) {... With other functions, the has_parent selector can be used for similar purposes.
  17. Yes, it can be done using the Google Sheets API (https://developers.google.com/sheets/api). I recommend the PHP Quickstart guide at https://developers.google.com/sheets/api/quickstart/php. However, be aware of the usage limits described at https://developers.google.com/sheets/api/limits. These, combined with possible performance limitations, mean that it would probably be best to get the data into PW pages – and not to display the data directly on web pages using API calls from the template file. There are various ways you could pull the data into PW pages. One would be to run a Google API call each time the page is saved (for example, hooking on saveReady). Another would be using cron (or the PW module Lazy Cron) for regular updates.
  18. Prepros (https://prepros.io/) works well for me for most things. It's (much) less customizable than gulp and similar tools, but makes life simple, and in practice I've rarely wanted it to do something it couldn't - though obviously YMMV. It can slow up when watching large numbers of files, and the FTP could be developed, but although it may not be quite as cool as gulp etc, it saves me a good amount of time!
  19. Note that cookies are not secure, so you shouldn't store passwords in them. Even hashed passwords could potentially be used to access your system. You'll find lots of advice and ideas for how to go about things via Google (other search engines are available). My own basic suggestion would be to use sessions rather than cookies. EDIT Just thought. This page might be useful: https://processwire.com/docs/security/sessions/
  20. I'm not sure exactly what you're trying to do, so I'm guessing here, but it sounds as if you might need to set output formatting to false before doing it. Useful posts: There are many textformatters available at https://processwire.com/modules/category/textformatter/, and it's quite easy to write your own if necessary.
  21. I'd suggest writing a script (https://processwire.com/docs/front-end/include/) to load the data from a CSV or similar, with the data including a URL or path to each image. The structure of the data file could be whatever is easiest to handle in the script. It doesn't sound as if what you exported is all that helpful as an example. A couple of posts that might be useful: https://processwire.com/talk/topic/1153-adding-images-to-a-page-via-the-api/ https://processwire.com/talk/topic/21183-adding-image-to-page-via-api-page-images-add-solved/ Note that adding data to the custom fields is straightforward, and just like adding to the image description. For example, if you have a custom field named "caption": $addedImage->caption = "Text for the caption.";
  22. If I understand you correctly, you are using a select option field. Looping through the selected options is described at https://processwire.com/docs/fields/select-options-fieldtype/#outputting-selected-options-on-a-page You could then use if statements to test with something like this: if ($media->title == 'facebook' { ... Or a switch statement might be neater if there are several options: switch ($media->title) { case 'facebook': $soc = 'facebook'; break; case 'twitter': ...
  23. One other suggestion: if any PW selectors turn out to be slow across so many records, try using the RockFinder3 module (https://github.com/baumrock/rockfinder3).
  24. If you look at the HTML for the material from the CKEditor field, is the image element appearing there as expected? And if you add one of the images to the page directly (not using CKEditor) so that the image appear correctly, is the value of the src attribute the same as for the image element in the CKEditor material?
  • Create New...