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

188 Excellent

About Kiwi Chris

  • Rank
    Sr. Member

Profile Information

  • Location
    New Zealand

Recent Profile Visitors

1,210 profile views
  1. 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.
  2. You could use PHP output buffering to read your file into a variable. Something like: ob_start(); include('./emailbody.inc'); $emailBody = ob_get_clean();
  3. 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.
  4. 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.
  5. 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. 😊
  6. 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.
  7. 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.
  8. Sorry, I checked a case outside of a repeater, and you're right. I have dependent selects working, but only after a save. What I had was several page fields outside a repeater that used custom code in ready.php, and a dependent page field inside a repeater, but the containing page was always saved first, so of course the dependent page fields in the repeater worked. Thanks to your help in another thread: I can also get dependent selects working inside a repeater if I save after each field is updated. There doesn't seem to be an option to refresh an individual page field either inside or outside a repeater via an ajax call other than by the selector string option you've mentioned.
  9. @Robin S That seems to partially work, but it seems to have issues if a custom selector returned by a hook in ready.php, rather than a selector configured in the field properties. I'm not sure if there's a way around that?
  10. It's a while since this thread has been updated, so I thought I'd check whether there's been any update on anyone finding a way to make dependent selects work dynamically inside repeaters. I've got dependent selects inside repeaters working ok IF I save each time I make a selection, but that's a bit clunky for an end user. I realise there are issues with the way repeaters generate ids that might make ajax based updates impossible but it would be handy. I originally rejected using pagetables as there are only every going to be a handful of repeater items for each page, and the modal edit method with pagetable fields, rather than inline editing, along with the need to publish each item is not as intuitive as repeaters. A repeater field would be my preference, although I guess I could go back to using pagetables/pagetable extended, but they're not as convenient for end users as a repeater, apart from the issue around dynamic selects.
  11. @Robin SThanks that's what I was looking for. hasPage returns the repeater page. I think I now have the capability to deal with most scenarios for page fields where they have dependencies. I think they still rely on the page being saved, but that's OK for now, although it would be great if I could get them updating via ajax. Inside my hook I now have something like this: if ($event->object->hasField == 'pageBatch') { $inputfield = $event->object; $repeater = $inputfield->hasPage; //Now possible to refer to repeater fields in hook. }
  12. getForPage() doesn't help. if ($event->object->hasField == 'pageBatch') { bd($event->arguments(0), "Trigger Object"); $page = $event->arguments('page'); if ($page instanceof RepeaterPage) { $page = $page->getForPage(); bd($page->dispatchItems, "DispatchItems"); } Here is the segment of of code. the first bd() indicates that $event->arguments(0) is returning the page the repeater field is used on, NOT the page of the current repeater item, even though pageBatch is a field within the repeater. bd() doesn't even get called at the second instance, so even though the field pageBatch is contained within the RepeaterPage, I can't work out how to refer to any of the fields within the repeater.
  13. I have a hook inside ready.php and I'm trying to get one page reference field pageBatch inside the repeater to update based on the value of another page reference field also inside the repeater, but so far haven't been able to get it to work. Is this possible, or is it a limitation of repeaters? Ideally I'd prefer to use a repeater than pagetable, as there will normally only ever be two or three items in the repeater, and the data entry with repeaters is a bit more intuitive for users as they don't have to remember to publish, and the entry is inline, rather than pop-up modals. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { // pageBatch is a page reference field in a repeater if ($event->object->hasField == 'pageBatch') { $page = $event->arguments('page'); //returns the page that the repeater field is in, not the current repeater item $repeater = $page->repeaterField; //Want to be able to get the value of $repeater->pageField (a page reference field in the repeater) //Can refer to a page reference field in the page the repeater is in ok though eg $page->pageField works //but not a page reference field inside the repeater $repeater->pageField } });
  14. I've done some further investigation, and on a site without this module, Lister/Lister Pro will show hidden + unpublished as long as the template itself has access control set. It won't work if only the parent has access control set. Access control must be explicitly set on the template in question, as Lister (Pro) doesn't appear to look at access control inheritance. With AdminRestrictBranch installed, even if a template does have explicit access control, and no other modifications to access control, it does seem that the hidden + unpublished option in Lister/Lister Pro doesn't work, although using the include all hook, or doing the equivalent creating the lister via the API, setting allowIncludeAll property to true, and including include=all in initSelector property of the lister does provides provides the expected results.
  15. Yes, I've now also confirmed on a site that doesn't have this module installed. I'll go back to @ryan and ask him about ListerPro. It has an option to include hidden + unpublished but doesn't actually do anything. Thanks for the workaround. If I get ListerPro working as expected without this module without needing a workaround, I'll recheck again with this module to confirm it has no side effects.
  • Create New...