Jump to content

AAD Web Team

  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by AAD Web Team

  1. In our page template cache settings we have, "Clear cache for saved page and parents", which works as expected when using ProcessWire (3.0.200) interactively.

    When we manipulate pages with the same template from the API though we get this:

    $page->save(); // Cache clear happens as expected
    $page->save('my_field'); // Cache clear is not triggered – it's as if the page has not been saved (though the field has been saved correctly).
    $page->setAndSave('my_field', $value); // Cache clear is not triggered

    Is this the expected behaviour? If so, could the $page->save() documentation be updated to mention this difference?

    • Like 2
  2. Hi everyone, we've experienced an issue where FormBuilder is rejecting the client side validation of image uploads for .jpeg images, even though they are allowed as a file extension.

    We did also submit a Github issue: https://github.com/processwire/processwire-issues/issues/1656

    Expected behavior

    Both forms have the same form and file fields settings. Therefore both should accept a .jpeg image.

    Actual behavior

    One form accepts a .jpeg image happily, the other pops up with an error message saying the image does not match an expected file type. This is using the same image for both forms.

    Optional: Screenshots/Links that demonstrate the issue

    Image I'm using to test:

    Steps to reproduce the issue

    I'll include both forms export codes:

    Working form import code;
    { "required": false, "columnWidth": 0, "roles": { "form-submit": [ "guest" ], "form-list": [], "form-edit": [], "form-delete": [], "entries-list": [], "entries-edit": [], "entries-delete": [], "entries-page": [], "entries-resend": [] }, "flags": 0, "pluginActions": [], "framework": "Bootstrap5", "submitText": "Submit news item", "successMessage": "Thanks for your submission. Refresh the page to see your item at the top of the list.", "errorMessage": "One or more errors prevented submission of the form. Please correct and try again.", "frBasic_cssURL": "/site/templates/css/form-builder.css", "emailSubject": "Staff news submission [SEC=OFFICIAL]", "responderSubject": "Staff news submission [SEC=OFFICIAL]", "saveFlags": 75, "savePageTemplate": 64, "savePageParent": 8349, "savePageStatus": 1, "savePageFields": { "name": "headline", "1": "headline", "150": "body", "102": "link_url", "44": "image" }, "listFields": [ "headline", "email" ], "entryDays": 366, "emailTo": "webteam@aad.gov.au", "emailFrom": "email", "responderFromName": "AAD Web Team", "responderReplyTo": "webteam@aad.gov.au", "responderTo": "email", "emailFrom2": "webteam@aad.gov.au", "mobilePx": "55em", "partialEntryDays": 14, "spamEntryDays": 7, "frBasic_itemContent": [ "description", "out", "error", "notes" ], "frBootstrap5_noLoad": [ "framework", "jquery" ], "frBootstrap5_bootURL": "/site/modules/FormBuilder/frameworks/bootstrap5/", "allowPreset": 0, "skipSessionKey": 0, "useCookies": 0, "frBasic_noLoad": [], "spamFlags": 0, "spamWords": [], "children": { "headline": { "type": "Text", "label": "Headline", "required": 1, "columnWidth": 0, "requiredAttr": 1, "maxlength": 300 }, "body": { "type": "Textarea", "label": "Body", "notes": "There’s a limit of about 650 words (4000 characters) in this field, but 150 words or less would be ideal.", "required": 1, "columnWidth": 0, "rows": 5, "maxlength": 4000, "requiredAttr": 1, "collapsed": "0", "minlength": 0, "showCount": "2" }, "email": { "type": "Email", "label": "Email address", "description": "Please provide your email address. It will *not* be displayed with the news item, but will enable the web team to get in touch if there's an issue with your submission.", "required": 1, "columnWidth": 0, "rows": 5, "requiredAttr": 1, "maxlength": 512 }, "link_url": { "type": "URL", "label": "Optional hyperlink to more information", "required": false, "columnWidth": 100, "maxlength": 1024, "requiredIf": "link_text!=''" }, "image": { "type": "FormBuilderFile", "label": "Optional image", "notes": "Allowed file types: jpg, jpeg, png\nMaximum file size: 5mb", "required": false, "columnWidth": 0, "extensions": "jpg jpeg png", "maxFiles": 1, "maxFileSize": 5242880 } } }

    Not working form import code:
    { "required": false, "columnWidth": 0, "roles": { "form-submit": [ "guest" ], "form-list": [], "form-edit": [], "form-delete": [], "entries-list": [], "entries-edit": [], "entries-delete": [], "entries-page": [], "entries-resend": [] }, "flags": 0, "pluginActions": [], "framework": "Bootstrap5", "submitText": "Submit advertisement", "successMessage": "Thanks for your submission. Refresh the page to see your item at the top of the list.", "errorMessage": "One or more errors prevented submission of the form. Please correct and try again.", "frBasic_cssURL": "/site/templates/css/form-builder.css", "emailSubject": "Staff classifieds submission [SEC=OFFICIAL]", "saveFlags": 11, "savePageTemplate": 67, "savePageParent": 8377, "savePageStatus": 1024, "savePageFields": { "name": "item_name", "137": "category", "1": "item_name", "150": "body", "102": "link_url", "44": "image", "122": "document", "141": "contact_person", "92": "email", "138": "phone_x", "139": "phone_m", "140": "phone_o" }, "listFields": [ "category", "item_name", "contact_person" ], "entryDays": 60, "emailTo": "webteam@aad.gov.au", "emailFrom2": "webteam@aad.gov.au", "responderSubject": "Auto-Response", "mobilePx": "55em", "allowPreset": 0, "skipSessionKey": 0, "useCookies": 0, "partialEntryDays": 14, "spamEntryDays": 7, "frBasic_noLoad": [], "frBasic_itemContent": [ "description", "out", "error", "notes" ], "spamFlags": 0, "spamWords": [], "frBootstrap5_noLoad": [ "framework", "jquery" ], "frBootstrap5_bootURL": "/site/modules/FormBuilder/frameworks/bootstrap5/", "children": { "item_details": { "type": "Fieldset", "label": "Item details", "required": false, "columnWidth": 100, "children": { "category": { "type": "Select", "label": "Choose a category", "required": 1, "columnWidth": 30, "defaultValue": "For sale", "options": "=\nFor sale\nFor rent\nGiveaway\nWanted\nMiscellaneous" }, "item_name": { "type": "Text", "label": "Item name", "required": 1, "columnWidth": 70, "requiredAttr": 1, "maxlength": 300, "stripTags": 1 }, "body": { "type": "Textarea", "label": "Description", "notes": "**Do not include website addresses in the description.** They will not be clickable links and may break the visual layout of the advertisement. You can either use the website field provided, or attach a document if you need to list multiple website addresses.", "required": false, "columnWidth": 0, "rows": 5, "maxlength": 1200, "requiredAttr": 1, "stripTags": 1 }, "link_url": { "type": "URL", "label": "Website (optional)", "required": false, "columnWidth": 100, "maxlength": 1024, "requiredIf": "link_text!=''" }, "attachments": { "type": "Fieldset", "label": "Attachments (optional)", "required": false, "columnWidth": 0, "children": { "image": { "type": "FormBuilderFile", "label": "Image", "notes": "Allowed file types: jpg, jpeg, png\nMaximum file size: 5MB", "required": false, "columnWidth": 50, "extensions": "jpg jpeg png", "maxFiles": 1, "maxFileSize": 5242880, "collapsed": "0", "descRows": 0, "descLength": 2048, "hideInputs": 0, "usePreview": 0, "useHeader": 0 }, "document": { "type": "FormBuilderFile", "label": "Document", "notes": "Allowed file types: pdf, docx, doc, rtf\nMaximum file size: 5MB", "required": false, "columnWidth": 50, "extensions": "pdf docx doc rtf", "maxFiles": 1, "maxFileSize": 5242880 } } } } }, "contact_details": { "type": "Fieldset", "label": "Contact details", "description": "Your name is required. Please provide at least one method of contact.", "required": false, "columnWidth": 100, "children": { "contact_person": { "type": "Text", "label": "Contact person", "notes": "***Must* be a member of staff.**", "required": 1, "columnWidth": 0, "requiredAttr": 1, "maxlength": 2048, "stripTags": 1 }, "email": { "type": "Email", "label": "Email address", "required": false, "columnWidth": 0, "rows": 5, "requiredAttr": 1, "maxlength": 512 }, "phone_numbers": { "type": "Fieldset", "label": "Phone numbers", "notes": "**Numbers only – no spaces or punctuation please**", "required": false, "columnWidth": 0, "children": { "phone_x": { "type": "Text", "label": "Extension", "required": false, "columnWidth": 0, "maxlength": 4, "stripTags": 1 }, "phone_m": { "type": "Text", "label": "Mobile", "required": false, "columnWidth": 0, "maxlength": 10, "stripTags": 1 }, "phone_o": { "type": "Text", "label": "Other", "required": false, "columnWidth": 0, "maxlength": 10, "stripTags": 1 } } } } }, "classifieds_policy": { "type": "Fieldset", "label": "Classifieds policy", "required": false, "columnWidth": 0, "children": { "agreement": { "type": "Checkbox", "label": "Advertisements that do not adhere to this policy will be removed.", "description": "", "required": 1, "columnWidth": 0, "checkedValue": "1", "checkboxLabel": "I have read and agree to these terms" } } } } }


    • ProcessWire version: 3.0.200
    • PHP version: 7.4.3
    • FormBuilder: 0.5.3
  3. Thanks @bernhard and @Jan Romero. I didn't think of how status works as a bit field, and I've never used the bitwise 'or' operator in a selector. The code snippet with Page::statusHidden is very useful, thank you.

    The part of the documentation I found confusing was in the selectors documentation where it says, "Pages with hidden or unpublished status will not appear in the results from database-querying selectors that can return multiple pages (i.e. functions that return the PageArray type). For instance $pages->find(), $page->children(), etc."

    However, I understand it now. Thanks @Robin S for explaining the underlying logic to why $page->children() and $page->parents() work differently with hidden pages. I can see from your linked post how this has been discussed previously. Unfortunately, in my forum searching before asking this question I didn't come across your post – so thanks for pointing me to it.

    • Like 3
  4. We're trying to get all the parent pages of a page in order to display a breadcrumbs trail on the web page. We're using:


    … to get all the non-home parents ready to display. We didn't want to include hidden pages in the parents list, and based on the selector documentation I thought they would be excluded, but the hidden pages are returned in the list. Is this how it's supposed to be?

    In order to not retrieve the hidden pages we also tried:


    … but this still returned the hidden parent pages.

    Can anyone help with this? Is the documentation wrong, or am I misunderstanding it? We're using ProcessWire 3.0.184.

  5. Hello, we've had some selectors no longer work after updating from ProcessWire 3.0.165 to 3.0.184.

    This particular selector will find the 3 most recent news items created within the last 6 months to display as a summary on the home page.


    This selector worked on 3.0.165:

    template=staff-news-item, created>=6 months ago, created<=now, sort=-created, limit=3, include=hidden

    But on 3.0.184 it returns 0 results. It doesn’t crash or log any warnings. It just doesn’t return anything.

    After changing to this, it now works again:

    template=staff-news-item, page.created>=-6 months, page.created<=now, sort=-created, limit=3, include=hidden

    This also works, with inconsistent use of page.created:

    template=staff-news-item, created>=-6 months, page.created<=now, sort=-created, limit=3, include=hidden


    Is anyone aware of selector changes in recent updates that would cause the selector to break?

  6. You could also use Matomo analytics (open source), which keeps track of site search keywords and searches with no results, as well as the most common pages visited as a result of a site search.

    I reckon it’s ok to log searches to a file in ProcessWire as well. I was previously logging searches with no results to the messages log with:

    wire('log')->message("No results for $searchTerms");

    Or to log all results to a separate search log with:

    wire('log')->save('search', $searchTerms);

    Because the log files are saved in a consistent space-separated format they'd be possible to parse with a script (maybe reporting the results through a ProcessWire page), or import into a spreadsheet program.

    We use the paid Form Builder module to allow users to answer a 'was this page helpful' question at the bottom of any page, including search.

    Another way of recording the success of the search could be to put the results through an intermediate PHP script that logs the search position of the chosen search result, before redirecting users on to the actual result. So you could see if the first match is mostly chosen, or something further down the list.

    • Like 3
  7. G’day,

    We’re about to put one of our ProcessWire sites into a Git-based source control system. The repository is private, but I still want to keep passwords out of it. I’ve been thinking about how to handle the database password in /site/config.php (I’ve read the documentation about securing the config.php file itself). I’ve thought of the following options:

    1. Just leave config.php as-is, with the database password in plain text. Make sure config.php is added to the .gitignore file. [But I’d actually like to have config.php file in source control given it’s vital to the operation of the system.]
    2. Create a PHP file outside of the web root, something like passwords.php, which contains a databasePassword() function. Include this file from config.php and reference the function. [I don’t like this because it creates a possibly obscure dependency outside the site directory.]
    3. Set the database password in an environment variable in the PHP-FPM configuration file (env[DB_PASSWD] = MyPassword). Then use PHP’s getenv() function in the config.php file. [Maybe not very secure, and then doesn’t work when the ProcessWire API is accessed from a stand-alone script.]
    4. Set the database password in an environment variable defined in the .bashrc file. Use the getenv() function in config.php. [Maybe not very secure.]
    5. Set mysql.default_pw in php.ini [Comments in this file say this would be a bad idea.]

    None of these options seems ideal. Does anyone have any suggestions?



  8. I was trying to use the advanced text search (#=) operator in a selector, and I couldn’t work out why my search for the text:

    +cat dog

    wasn’t working properly (the plus sign was being ignored), while a search for:

    dog +cat

    works fine. Also, prefixing words with minus always worked fine. Phrase searching with double-quotes wasn’t working, but it was fine with parenthesis.

    After a while I realised this was due to the $sanitizer->selectorValue() function I was using on the query string before using it in the selector. The following things are true:

    $sanitizer->selectorValue('+cat dog') === 'cat dog'; // Discards the leading plus sign, search doesn't work as expected.
    $sanitizer->selectorValue('dog +cat') === '"dog +cat"'; // Keeps the plus sign and puts double-quotes around the string.
    $sanitizer->selectorValue('-cat dog') === '"-cat dog"'; // Keeps the minus sign and puts double-quotes around the string.
    $sanitizer->selectorValue('dog -cat') === 'dog -cat'; // Keeps the minus sign, no double-quotes.
    $sanitizer->selectorValue('"jet black cat"') === '"jet black cat"'; // Keeps double-quotes; phrase searching doesn't work.
    $sanitizer->selectorValue('jet "black cat"') === 'jet black cat'; // Discards double-quotes; phrase searching doesn't work.
    $sanitizer->selectorValue('jet (black cat)') === 'jet (black cat)'; // Phrase searching works.

    These effects seem confusing. Is it something that needs to be fixed in ProcessWire, or is there a different way I should be using to sanitise the query string? The documentation recommends surrounding the query text with double-quotes but this doesn’t help with these examples.

    We’re using ProcessWire 3.0.164.

  9. I found the following to be a bit confusing, so I'm posting it to check if my understanding is correct…

    If we're looking for a page at a particular path that unfortunately has a comma in it (I'm aiming to get rid of all commas in URLs in future, but there's a legacy of existing ones to deal with):

    $path = '/news/2012/australia,france';

    We had the code:

    $result = $pages->get($path);

    This was throwing an exception inside the ProcessWire core:

    Error: Exception: Unknown Selector operator: '[empty]' -- was your selector value properly escaped? (in /srv/www/antarctica/wire/core/Selectors.php line 420)

    The mention of 'escaped' made me think to use sanitizer on the path before using it in a selector. So I changed the code:

    $safePath = $sanitizer->selectorValue($path);
    $result = $pages->get($safePath);

    This was surrounding the path with double-quotes before passing it through. However I was still getting the same error (with some slightly different details).

    Then I realised that despite the error message mentioning 'selector', $pages->get() isn't actually treating the my $safePath variable as a selector string, but as a string that contains a page path, which is why it still crashes.

    Then I tried this:

    $safePath = $sanitizer->selectorValue($path);
    $result = $pages->get("path=$safePath");

    This works! (i.e., it doesn't crash. We don't find any page – I don't think ProcessWire can have commas in paths anyway. So it's fine to return a NullPage, I just wanted it to not crash.)

    However, using 'path=' in a selector isn't documented, so I'm not sure if this is something you're supposed to do. The instructions suggest that you use either a selector or a page path, but not a page path within a selector.

    Does anyone have any advice about this? Is 'path=' supported in a selector? How does the $pages->get() or $pages->findOne() method know if it's being passed a selector string or a string that contains a page path?

  10. We've found the same thing on PW 3.0.148 with any custom image fields, when the images are inside a repeater. After drag-and-dropping the images in, on the first save after that, any custom field text (e.g. caption, photographer) is simply lost. In a subsequent save, the text is saved fine.

    Every time a new image is dragged in, the page must be saved before adding text to the custom fields for that image. Otherwise text entered for the new image is lost (text previously entered for other images in the same repeater is fine).

    This seems to have been logged as a bug on 23 January: https://github.com/processwire/processwire-issues/issues/1070

    • Like 1
  11. Thanks @Robin S – that's an excellent explanation. I didn't previously know about the difference between PageFinder and in-memory selectors. It'd probably be good if allowable date formats were explained on the selectors documentation page. (I'm not sure what the best process for suggesting documentation updates is.)

    • Like 3
  12. The selectors documentation has the example, when working with a Datetime field of:


    Does this mean we can use any format compatible with PHPs strtotime function? I tried:

    my_date>=5 weeks ago

    …and it seemed to work. What about when using Unix timestamps? The strtotime documentation suggests you'd need:


    … but we just had:


    …and it seemed ok.

    Anyway, given this all seems to work we can just keep doing it, but I wanted to check that this is a 'supported' way to use dates in selectors, so I know we can rely on it.

  13. EDIT: I'm still curious whether this is possible, but given this template has very low usage on our site I've decided to change it to a Verified URL field instead of a Page Reference. Problem solved!


    I have a 'redirect' template which consists of basically just a Page Reference field (it was designed for our in-page 'visual' navigation and works perfectly there).

    However, in our left navigation I'd also like it to point to the URL of the referenced page rather than the URL of the page that has the redirect template applied.

    I tried 'xitem_tpl' => '<a href="{target_page->url}">{title}</a>', but it doesn't appear to accept the target_page->url syntax (it just points to the URL of the current page instead). Is there a way to achieve this? I'd prefer not to have to hide that template type from the left navigation if at all possible.



  14. Hi again @bernhard and @wbmnfktr,

    It should now be fixed. Well, I think there's still some kind of bug in the way Chrome for Android behaves, but I was able to completely turn off the 'touch' option for the modal menu instance of Fancybox. Swiping is not needed for the menu so that has fixed the issue, and it doesn't seem to have had any other adverse effects from what I can see so far. ?

  15. I'm just resurrecting this old thread to let you know that our SCARCOMNAP 2020 conference site built in PW is being discontinued. It is being replaced with a site hosted by the conference organiser, so no longer in ProcessWire. The URL will redirect, so I wouldn't want there to be any confusion for people who happen to visit it from here (or the Showcase while it's still listed there).

    I'm not sure how to remove a site from the Showcase... is this notification sufficient? Thanks!

    • Sad 1
  16. Thanks @wbmnfktr, I'll certainly have to have a play around with those options (I've left them all at their defaults).

    However, I would've thought the resulting behaviour should be the same across browsers. In this case, it's only a problem with the Android version of Chrome. In all other browsers that I've tested it behaves as it should, where the menu only closes if you tap the close button or outside the blue menu area.

  17. 17 hours ago, bernhard said:

    This issue is fixed now, but when I try to scroll down the menu further than shown on the screenshot the modal closes:

    This is an odd one. It seems to only happen in the Android version of Chrome. If you keep your finger on the menu while scrolling it works, but as soon as you touch the blue background and scroll, the modal closes. In my testing, it doesn't happen in Firefox on the same type of phone, nor does it happen in Chrome or Safari on iOS.

    I'm not sure if this is a bug with Fancybox or a bug with Chrome for Android - either way I'm not sure how to go about fixing it or even where to report the bug. I'll keep Googling to see if I can find anyone else with the same issue.

  18. G'day … I'm not sure if this is an actual problem, or just my lack of understanding about how this is supposed to work. We're using PW 3.0.131 with the ImageExtra 1.0.6 module. I'm using the API to automatically import lots of pages with images into PW from a different web CMS.

    I'm having trouble updating some of the custom image fields, which don't save unless a core image field is also updated.

    In code, where $p is a particular page and $img is a particular image on that page, this works:

    $img->description = 'foo'; // Standard field
    $img->photographer = 'bar'; // Our custom field created with ImageExtra
    $p->save(); // Updates the record in the database.

    But this doesn't work:

    $img->photographer = 'bar'; // Our custom field created with ImageExtra
    $p->save(); // Makes no difference to the record in the database.

    This also doesn't work:

    $img->photographer = 'bar'; // Our custom field created with ImageExtra
    $p->save('photographer'); // Makes no difference to the record in the database.

    In all cases the $p->save method returns true to indicate success.

    Can anyone help me understand what's going on here? Thanks!

  19. Thanks for the feedback @bernhard. May I ask what type of phone and which browser that is? It was tested extensively across a range of devices and browsers using BrowserStack, but there are so many possible combinations these days it's easy to miss some.

    Your feedback on the navigation is also appreciated. The content presented across the site is very linear in nature as it is based on Douglas Mawson's book, hence the previous and next links. We'll take another look.

  • Create New...