Jump to content

Kiwi Chris

  • Content Count

  • Joined

  • Last visited

  • Days Won


Kiwi Chris last won the day on November 13 2017

Kiwi Chris had the most liked content!

Community Reputation

208 Excellent

About Kiwi Chris

  • Rank
    Sr. Member

Profile Information

  • Location
    New Zealand

Recent Profile Visitors

1,372 profile views
  1. That's quite a timely update. Just this week I've been working on a site where there are a lot of selectors that depend on various levels of parent/child relationships, and I was wondering about performance, so if this area of Processwire has had a big performance improvement it's very well timed.
  2. The selector in the following code included in a template is returning nothing, however if I take out the compId.resultsdate<={$today} bit, it works fine, although obviously not filtered on the date field. $today = strtotime(date('Y-m-d')); $setImages = $pages->find("template=competitionImage, compId={$page->id}, compId.resultsdate<={$today}, compSubject.name=s, imageRating.title=Merit|Honours,check_access=0"); Here's the results of an example from Tracey Debugger templates_id=79, resultsdate<=1587729600, status<2048 SELECT pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_resultsdate AS field_resultsdate ON field_resultsdate.pages_id=pages.id AND (((field_resultsdate.data<='2020-04-25 00:00:00' ) )) WHERE (pages.templates_id=79) AND (pages.status<2048) GROUP BY pages.id Over in my ready.php I have inside a hook that refers directly to the page template that's used for the pages in the page field above: $today = strtotime(date('Y-m-d')) $event->return = $event->pages->find("template=competition,eventEnd>={$today},eventStart<={$today}"); In this case the filtering on date fields (albeit different ones) works fine. Can anyone suggest why the filter on the date subfield of the page field isn't working? Just to confirm, I do have a date value in the field, and it is a date before today. 🙂 The problem may be something blatantly obvious, but I can't for the life of me figure out why the selector is returning no results when I include the date filter.
  3. I only have one kid, so in some ways that keeps things easier, although she's in the office with me on the other PC which can make things interesting at times. We are allowed out walking as long as we keep to our neighbourhood and stay a safe distance from other people. Things have been pretty relaxed up until Sunday when the oven died, which made things a bit more inconvenient as we've been doing a lot of home baking, but that is out of the question now until I can get someone to repair it, or buy a replacement, which either way looks like at least a week away. At least there's a good chance of eliminating the virus completely here within the next few weeks, which will allow life to return to some semblance of normal, but the borders will likely be closed well beyond the end of the year.
  4. @adrian, thanks, I've got it sorted. It was a typo in a field name on my part. I didn't realise it would drop the whole filename pattern rather than just the incorrect part, but once I corrected that, it's all good.
  5. I'm trying to use this module, but currently no renaming is happening, either on upload or after save. My rule is : {$page->compGrade->title}_{$page->compSubject->title}_{$page->compMedium->title}_{$page->title} $page->compSubject and $page->compMedium are Options fieldtype. I get for example: imgp0887_upload_tmp.jpg which is definitely not right. I'm on PW 3.0.144 There's not by any chance an issue with the module not handling mixed case field names? Processwire itself does allow mixed case field names, however I've struck several modules including from Ryan himself, that convert everything to lowercase, to match database table names. That's the only thing I can think of that might be causing renaming not to work. Here's screenshot of configuration below:
  6. Will the custom PHP code option work with multiple statements? I have a tree structure like: Members -Member 1 -page 1 -page 2 -Member 2 Competitions ... I want to restrict logins with role member to just their own member branch, and that works fine currently with: return "/members/" . ($user->name); What I'd like to do is if a login has the role 'membership-secretary' set their branch to Members, and then any other admin roles to home, as I can use template permissions to prevent them accessing parts of the site they shouldn't, but I'm trying to make it easier on the 'membership-secretary' role so they only have to see the branch of tree they'll work with. I understand the module doesn't support restricting to multiple branches simultaneously, but I don't think that's what I'm trying to do. I only want to grant access to a single branch to a given user, however depending on their role, they will have access at a different level in the page tree. I had a go with if($user->hasRole('competition-secretary') || $user->hasRole('membership-secretary'){return "/members/";}else if($user->hasRole('member'){return "/members/" . ($user->name);}else{return "/"} statement, but that caused a 500 error, so I'm just checking whether this kind of use case scenario is possible?
  7. One thing to remember with Processwire is that while the default behaviour, and that of most built in fieldtypes is to use one table per field, like with most things, Processwire is incredibly flexible, so if you have a use case where a single table with multiple fields will be a more efficient way to store and access data, Processwire supports that too through custom field types, and indeed their are some built in fieldtypes that actually do work this way, such as map markers. Profields also includes a table fieldtype which as it sounds, is a database table with multiple fields. It takes a bit of work to write a module to provide a custom fieldtype but there are examples in the modules directory such as fieldtype Events which is specifically intended as an example of how to make a fieldtype that corresponds to multiple database fields. https://modules.processwire.com/modules/fieldtype-events/ In answer to the question, "Is the Processwire database structure scalable", I'd say that's entirely up to the developer, as you can really choose whatever database structure you like, just it takes a bit more work if you want to store multiple fields per table, and usually the built-in fieldtypes and default behaviour works fine. Where I have noticed there can be a little bit of a performance hit is doing a large import from CSV where each field from the CSV file results in a separate insert operation to a different table, whereas with a traditional database table with multiple fields would result in just a single insert operation per record, and potentially fewer indexes to update as well. If you're doing single page additions via the backend, via user interaction, Processwire is plenty fast enough, and there are performance gains to be had at the read level if you don't need to read every single field from a page every time it's accessed in front end templates, eg building a menu, you probably only want title and url, so reading the entire page content as well is unnecessary overhead, but if the content is in a separate table, and you don't access it, you don't have that overhead. There are always performance tradeoffs, but I think Processwire has struck a good balance. A default that works well for most people, but the means to do things differently if you really need to.
  8. Although you can't create a global field, you can access fields from any page on any template, so you could create a settings 'page' that isn't visible on the site, but holds any fields that you want to use globally, and then access them in every template eg: $global = $pages->get('name=settings'); echo $global->myfield; Remember that in Processwire, everything is a 'page', but it doesn't have to be an actual visible page on your site.
  9. You could use PHP output buffering to read your file into a variable. Something like: ob_start(); include('./emailbody.inc'); $emailBody = ob_get_clean();
  10. Not quite. My client had the requirement for a barcode scanner that would work independently of a PC, with the potential to store data if a wifi connection was not available. There are Android devices that have a built in barcode scanner. The barcode scanner does function in a similar way to the device shown, but it is part of a small Android tablet, so no wires, and there's a button on the side of the tablet to click to trigger the scanner.
  11. The free edition of Delphi looks interesting, but then I saw the terms - once you generate more than $5000 in revenue per year you have to pay. The community edition of Microsoft Visual Studio doesn't have any revenue limits, although I've had issues with it crashing and corrupting project files, and losing dependencies, so something more reliable might be worth a look. Native apps connected to a REST API are something I've started doing via ASP.Net and Xamarin, but I'd be interested to see how to do it via Processwire, at least for the backend, as I suspect that might be easier to code than ASP.Net. At this stage I don't really need iOS or MacOS, just Android, so I guess I could use Android Studio for the front end. AFAIK, Apple doesn't build devices with integrated barcode scanners without having to write code, but there are Android devices that do, and the scanner simply becomes an alternative input method to the touch screen.
  12. I love the Christmas card. It's a good reminder that Processwire isn't just an incredibly useful collection of code for geeks, but is also a tool that allows people to provide for themselves and their families. I'm not sure how much my daughter understands what I do on the computer, but she does understand it helps pay for holidays and Lego amongst other things. 😊
  13. I don't really have anything public to show, as nearly all the work is back-end, but I thought I'd post here anyway as it's a pretty good example of just how powerful Processwire can be. About a year ago, I inherited an incomplete Craft website made by a designer. Apart from the usual company information site, it was supposed to provide a customer portal for clients of a wine bottling company to make bookings for production runs. Data for stock levels of goods like bottles and labels was to come from an inventory management system Unleashed https://www.unleashedsoftware.com/ Unleashed provides a REST API, so I had to integrate with that first by writing an API integration module, and then ended up using Processwire's core lazy cron module to periodically pull data from Unleashed using a custom module. The booking forms have a lot of conditional fields, eg if you are bottling a given wine variety, you should only be able to select labels that match that variety. All this conditional stuff was achieved with a lot of additions to ready.php. I also needed to be able to created a predefined set of pages when a new user is added if they have a 'client' role. Once again, more hooking in ready.php I've used the Admin Restrict Branch module so clients can only see their own records when they're logged in, but staff can see all records. Lister Pro provides the ability to search and view completed production runs. Part way through the project, as the client was happy with the way things were going, I was asked to add in logistics and dispatch which is provided by another company, which also runs Unleashed with a separate set of data, and with some clients who don't bottle wine, but will end up using the same portal, so using the roles and permissions inherent in Processwire, I set up production templates with separate roles to dispatch templates, so I could easily have clients assigned access to just the templates they need. Tracey Debugger got a thorough workout along the way, and the debugger console is an absolute killer tool for making quick changes to data when updating a live site to match changes from the dev site. At the start of this project, I'd used Processwire quite a bit, but never dived into module development or hooking, but I've now ended up with a reasonable idea how they work. @bernhard has produced some excellent tutorials which I found really helpful figuring out how to create modules, and other people like @Robin S have answered questions when I've got stuck. @ryan himself has been helpful when I've been trying to do things that push either the limits of my knowledge or Processwire or both 😋 . Could I have done this with other tools? Depends. Wordpress would have been as useless as using petrol to fight a fire, however something like ASP.Net COULD have done the job but would have probably made things a lot more complicated. In parallel, I've been working on building a REST API with ASP.Net for another client to integrate with an existing SQL Server database, and I've found that Visual Studio is inclined to break projects quite regularly, with dependencies getting messed up, or even whole configuration files getting corrupted when it has a hissy fit, so working with Processwire is a pleasure in comparison.
  14. LoginRegisterPro sounds great. So I don't go out and duplicate anything, a task I've been thinking for a while of bundling up into a module is the ability on creation of a user with a given role, to create a page and subpages with a predefined template structure. Currently I do this via ready.php and it works fine, but I figured it would be convenient and flexible as a module. (eg. Create login with role "customer", and then automatically create a page with template "customer" and sub-pages "customer-sales", "customer-support-requests", etc.. ) For a tree structure like for example: Customers -Customer 1 -Customer Sales -Customer Support Requests -Customer 2 -Customer Sales -Customer Support Requests ... Using this together with a module like AdminRestrictBranch makes it easy to let customers log in and manage their own content. If LoginRegisterPro won't cover this kind of login creation scenario, and no one else has something similar, I'll go ahead and start building a module.
  • Create New...