Jump to content

Kiwi Chris

Members
  • Posts

    266
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Kiwi Chris

  1. 21 hours ago, flydev ?? said:

    like this ?

    IMG_0849.thumb.JPG.83f5e27a6da6e0fd6da2b7acd3d8b65a.JPG

    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.

  2. 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.

    • Like 1
  3. 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. ?

    • Like 6
  4. 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.

     

    • Like 11
    • Thanks 1
  5. 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.

    • Like 4
  6. 22 hours ago, Robin S said:

    The dependent selects feature has only ever worked with the selector string option as far as I know.

    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.

     

  7. 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.

  8. @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.
    	}

     

  9. 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.

  10. 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
        }
    });

     

  11. On 11/7/2019 at 8:28 AM, Kiwi Chris said:

    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.

    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.

  12. 4 hours ago, adrian said:

    So just to confirm, do you agree that this module isn't having any impacts on the issue?

    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.

  13. 4 hours ago, adrian said:

    @Kiwi Chris

    Just looked at one of my sites and this is what I put in ready.php

    
    // lets non superusers view unpublished and hidden pages in listers
    // https://processwire.com/talk/topic/9346-not-all-specified-templates-are-editable-only-includehidden-is-allowed/?do=findComment&comment=143068
    $this->wire()->addHookBefore('ProcessPageLister::getSelector', function($event) {
        $event->object->allowIncludeAll = true;
    });

    Does this solve your problems?

    Thanks. This provided the result I needed. I actually added it to a custom module that added the hook, but same result.

    • Like 1
  14. @adrian I already have that option configured. In lister I get a message: 

    Quote

    Not all specified templates are editable. Only 'include=hidden' is allowed

    I know this issue has come up before, and Ryan has asked people to check if they have anything that is hooking permissions.

    With my site structure I have multiple clients who are restricted to what they can edit via this module, however they all have pages they can edit using common templates, so there will be some pages using a given template a user can edit and others they can't.

    The template in question in my lister definitely is editable for the user, and published pages for the user show up fine.

    I think AdminRestrictBranch is the only module I have installed that does hook permissions, so I thought it would be worth checking whether other people are using it and Lister/ListerPro together successfully. 

  15. I'm not sure whether it's relating to having this module installed or Lister/ListerPro by @ryan but I seem to be having issues displaying unpublished pages in Lister/ListerPro, and Ryan did mention to check on any other modules that modify permissions.

    Is anyone else using this with custom Listers or ListerPro? If so, are users able to view their own unpublished pages OK?

  16. 13 hours ago, bernhard said:

    $grid must be a RockTabulatorGrid object, not RockFinder2. It seems that your code is wrong.

    Oops! I copied and pasted from the example you gave a few posts back. That will teach me for just copying without trying to understand the code. ?

    I realise RockFinder and RockGrid are still works in progress, and full documentation is coming. ?

    Another issue I've struck is I get the following error in the RF2 sandbox: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bottlingco_pw.field_stockCode' doesn't exist

    (field is added via $rf->addColumns)

    If I change the field name to all lower case (stockcode), I get no error, but RockTabulator just shows 'Field not found' in the sandbox RockTabulator.

    It seems as though RockFinder is not translating a Processwire field name with an uppercase character in it into lowercase for the SQL query.

  17. On 10/16/2019 at 3:09 AM, bernhard said:

    They CAN certainly do. But it's not plug&play, it will need some more or less simple coding ? 

    I'm getting there... The order of installation turns out to be fairly important: RockMarkup2 then RockTabulator then RockFinder2

    I've got them all installed ok, but I'm getting the following error:

    Call to undefined method stdClass::setData() in RockFinder2

    on this line:

    $grid->setData($rf);

    Also I get a :

    PHP Warning: Creating default object from empty value in 

    when I save in the sandbox

    I'm running PHP 7.2

  18. 11 hours ago, bernhard said:

    Yes, perfect use case for RockFinder2 + RockTabulator - built exactly for situations like that.

    Build a custom admin page, as simple as that (https://processwire.com/talk/topic/17709-how-to-create-custom-admin-pages-aka-processmodules-yes-its-that-simple/?

     

    Thanks. I've already used your tutorial on building custom admin pages and found it really helpful.

    Rockfinder2 + RockTabulator are new to me, but it looks like they'll do what I want.

    • Like 1
  19. I have a site with the following structure:

    User
    -Orders
    -Materials
    User 2
    -Orders
    -Materials

    ...etc

    I'm using AdminRestrictBranch module with custom PHP code, so that users when they log in, can only access their records.

    return ($user->hasRole('client')) ? '/clients/'.strtolower($user->clientCode): '/';

    So far so good...

    Now I've been asked to add a new component in addition to the orders and materials, 'dispatch', however where this gets complicated, is I've been asked to separate this off and show it as a separate tab at the top (ie where Pages, Setup, Modules, Access etc go).

    I know everything in Processwire is essentially a page, and Modules and Access have their own links as they are sub-pages of Admin, so I can create a new link up here OK.

    The problem is with the default setup, you give access to one of these features or you don't.

    What I need is to be able to do is assign all users with role 'client' access to certain functions, but ONLY let them edit, view and create their own records.

    I can probably store the dispatch data under the user like I've done with Orders and Materials, but if so, I'll need to hide the page tree and create a separate dashboard so that I can have Orders and Materials under one heading, and Dispatch under another.

    One option I've seen that I wonder whether might be helpful, is Lister Pro. I don't have the module yet, and I can't tell clearly enough from the module documentation whether it will help me achieve what I need. I definitely don't want people with 'client' role being able to change what pages to show in lists themselves, but I do need them to be able to see their own records, edit them, and add new ones.

    Will Lister Pro help accomplish what I need, or are there other ways to achieve what I need, and importantly, what's likely to be the most efficient approach?

  20. I've tracked down the issue.

    Thanks @dragan for the example of how to use d function.

    it turns out one field in the selector had a leading space in the record that's not being returned, however it doesn't show in the editor.

    By changing the offending field, saving it, then changing it back, it made it have the correct value.

    I couldn't just save it, as Processwire didn't consider the field changed, even though it stripped out the leading space before displaying it in the editor.

    ie I had a text field productType that was supposed to be "FG" but was actually " FG" however editing the page displayed it as "FG".

    The record was orginally imported from CSV, so I either need to get my import to strip leading spaces, or get the editor to display them.

     

     

  21. I have a selector that matches on several fields to provide the records for a page reference field, but is behaving strangely with a couple of records.

    The two records use the same template and have identical field values for all fields but for the title and another field pageDescription which are not included in the filter.

    Both pages are visible and published, but only one page is returned, although if I do a search directly for the title of the page the selector does not return, it shows up.

    Does anyone have any idea why a selector would not return a matching record?

    Is there any possibility of database corruption (I'm using InnoDB)

  22. What I had to do was create two websites with webfaction, one using HTTP and one using HTTPS

    Go to Domains/Websites, then Websites

    In the HTTPS site, just use the standard Processwire .htaccess and make sure you've got the site set to use HTTPS.

    Create another site, using static/CGI/PHP template will do with the same domain name, but make sure it is using HTTP (not HTTPS) and in that one add the code you posted to the .htaccess file of the HTTP site.

     

×
×
  • Create New...