Jump to content

BillH

Members
  • Posts

    220
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by BillH

  1. 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); ...
  2. 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.
  3. 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!
  4. 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.
  5. 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.
  6. 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:
  7. 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/.
  8. 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.
  9. 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.
  10. 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!
  11. 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/
  12. 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.
  13. 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.";
  14. 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': ...
  15. 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).
  16. 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?
  17. If I understand you correctly, you'll find the answer here: https://processwire.com/docs/fields/select-options-fieldtype/ See the section titled "Getting the id property of an option when you only know the title".
  18. Might RockFinder speed things up sufficiently? Latest version at https://github.com/baumrock/rockfinder3. I'd expect it to reduce your query times greatly - probably well under a second. And you can keep using PW selectors.
  19. The field page2use4homepage will return a null page (id = 0) if no page is selected, which might be confusing things. I haven't tested, but I'd suggest using: (($page->id == 1) && ($page->page2use4homepage->id != 0))
  20. This happened to me once when I moved a site to a new server and accidentally used details for remote access to the first server for dbHost. Took me a while to figure it out! There can be various sorts of caching on the server, which may have been set up as a default by the hosting company without you being aware of it. They don't usually cause problems, but they might. What sort of server setup do you have?
  21. I suggest that first you find the error in the HTML as delivered to the browser, and then work out the source of the error. View the source of the page or your browser's developer tools ("Inspect"). If you can't work it out, try an HTML validator (e.g. https://validator.w3.org/). An <a> element within a <p> is certainly OK. With any luck, once you know what the error is, the cause will be reasonably clear. As a total guess, I suspect it'll be something in your template file.
  22. In what @kongondo suggests, replace "config" with "page" or "pages".
  23. Hadn't read your original post properly 🙁 Just another thought: do you need to use datetime fields? If there are a fairly limited number of possible start and end times during the day, you could set up pages for each time, and select using page reference fields. The time pages could have fields with formatted and numerical representations of the time. To find pages in a time range, you'd find the relevant time pages, and then use those to find the courses, something along the lines of this: $startTimes = $pages->find("template=times, time>=1200, time<=1400"); $endTimes = $pages->find("template=times, time>=1500, time<=1700"); $courses = $pages->find("template=course, start_time=$startTimes, end_time=$endTimes"); Not tested, but I think it'd work.
×
×
  • Create New...