Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by BillH

  1. 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?
  2. 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".
  3. 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.
  4. 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))
  5. 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?
  6. 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.
  7. In what @kongondo suggests, replace "config" with "page" or "pages".
  8. 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.
  9. I think the information you need is in this post: So, in brief, the values in a selector should be UNIX timestamps. Note that, in a template, if you get a date from a field it will be formatted according to the settings for the field, but you can use $page->getUnformatted('your_date_field') if you need the timestamp.
  10. If you can't put the iframe in a template (as @kongondo suggests) and need it in a CKEditor field, it'd be worth considering (if you haven't already) the Hanna Code module.
  11. And another question: how much data do you have in that field and across how many pages? I ask because one possible option, if you get really stuck, might be to delete the field and recreate it.
  12. Just another guess, but as the error occurred in modules.php (though this may just be when the memory ran out), it might be worth clearing compiled files as well, if you haven't done it already. Modules > Site > Clear Compiled Files (at the bottom of the page).
  13. When you say you have deleted the cache, do you mean your browser cache or PW cached files? If you haven't cleared PW cached files, they're at Site > Assets > Cache, and it's probably just the ones in Page that might be relevant. You can simply delete everything in the folder. Alternatively, you can clear cached page output by going to Modules > Core > PageRender > Settings. I don't know if this will help, but it's worth a try.
  14. You need to check whether there's something in the end date field. Then, if you're going to use the value in a function, you need to give it a suitable value if there's nothing in the field. For example: if ($single->End_date) { $end = date('d. m. Y', $single->getUnformatted('End_date')); } else { $end = date('d. m. Y', 0); // This would be 01.01.1970, but you might want something in the future } I also note that you are getting the unformatted dates from the fields and then formatting them again with the date() function. As you are just comparing values (at least in the code you have posted), you could simply use the values from the fields, or the unformatted value if it's easier to work with UNIX times. And you have $today == $start twice in your first 'if' condition!
  15. Trying to manage folders yourself would be seriously hard work and difficult, as discussed in this post: If a high proportion of your pages don't have images, and the total number of images is well under half the number of pages, you could take a one-image-per-page approach, with each image held in sub-page. A couple of modules that might help with this are: https://modules.processwire.com/modules/repeater-images/ https://modules.processwire.com/modules/process-visual-page-selector/
  16. The idea from @Ivan Gretsky of using template tags (which are on the Advanced tab of Edit Template) seems like a really good one. An approach to searching for tags on templates is here: Another possibility would be to prefix each relevant template name (e.g. "prefix-templatename") and then find using the "starts with" operator: $foundPages = $pages->find("template^=prefix"); But I think the tags approach would probably be better – more flexible, and organises things nicely on the Templates page in the admin.
  17. Thanks for the suggestion @Robin S Seems like a nice way of doing it. There no risk (however remote) of accidentally replacing something that shouldn't be replaced, and it's more resilient to change. And I suspect there are going to be more requests to change labels and the like in future, so this could be a good approach for keeping things well organised.
  18. Hanna Code may well be a good approach. Another option, if there's some way to logically deduce what classes should be added based on how an image is included in CKEditor or the like, would be to use PHP in the template to add the classes. Or if this was applicable to multiple fields or templates, you could look into writing a textformatter module to apply the classes (not difficult if you start by copying a simple one). If each image will always be handled in the same way, an option might be to use image tags (https://processwire.com/docs/fields/images/) and then use PHP in the template (or a textformatter) to apply classes based on the tags. Note that it's probably the CKEditor Advanced Content Filter (ACF) that's stripping out the classes - you could test by turning it off on the Input tab for the field. If it is ACF, then look at Extra Allowed Content (a bit further down on the Input tab). But you probably don't want to be editing the HTML by hand anyway.
  19. Many thanks @dragan, that works fine. The View tab is very slightly complicated by having a dropdown menu, so in case it's useful for anyone, here's a version that deals with that (changes "View" to "Preview"): wire()->addHookAfter("ProcessPageEdit::execute", function($event) { $render = $event->return; $template_name = "basic-page"; // Change to the relevant template name if (false !== strpos($render, "template_{$template_name} ")) { $render = str_replace("View<span id='_ProcessPageEditViewDropdownToggle'", "Preview<span id='_ProcessPageEditViewDropdownToggle'", $render); $render = str_replace("Exit + View</a>", "Exit + Preview</a>", $render); $event->return = $render; } }); Replacing just "View<span" would probably be enough, but perhaps there's a tiny risk it'd be in a rich text field as well.
  20. Thanks @adrian This works: $viewTab = $form->find("id=ProcessPageEditView"); However, I get the following, which doesn't have any attributes I can change, or anything that seems to correspond to the label or name of the tab: I think I must be getting something else wrong too!
  21. I'm trying to change the name of the View tab (client request) and can't work out how to get at the label property. The closest I've got to it is the url property. I've tried many things, including this: $this->addHookAfter('ProcessPageEdit::buildFormView', function($event) { $arguments = $event->argumentsByName(); bd($arguments); // Result: only 'url' $viewTab = $event->return; bd($viewTab); // Result: null }); And this: $this->addHookAfter('ProcessPageEdit::buildForm', function($event) { $form = $event->return; $viewTab = $form->find("id=ProcessPageEditView")->first(); bd($viewTab); // Result: false }); Does anyone know what I should be doing?
  22. Might this discussion help? Also, it might be useful to say what the overall purpose of your module is.
  23. @Jan Romero Yes, very good point. It could indeed cause a collision. In the particular solution I was copying from, it's not really a problem because the collision would occur when a user was being set up. And it's a membership society, so the user could be contacted and a different username arranged. Or I could improve the method!
  24. Your approach seems a good one. I don't know how you've configured things, but in similar circumstances I have usernames based on email addresses. As ProcessWire usernames are page names (mostly this just means replacing the @ with a hyphen), the following works for me: $email = $this->sanitizer->email($input->post->username); $username = $this->sanitizer->pageName($email); Sanitizing the email address might be a small improvement to your approach.
  • Create New...