Jump to content

Kiwi Chris

Members
  • Content Count

    149
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Kiwi Chris

  1. I think you need $this->page->save(); to actually save the settings, otherwise the values you set are not persistent?
  2. E-commerce is probably one of Processwire's weakest points in terms of a quick, ready to go integration, although hopefully that will change when Padloper 2 is released, but I was doing some browsing and came across a PHP e-commerce platform Aimeos https://aimeos.org/docs/latest/developer/architecture/ that grabbed my attention with this quote: Has anyone had any experience with it? I'm trying to work out how it would need to be integrated, (currently it supports Laravel, Symfony, and Typo3 off the shelf), but if there's an off-the-shelf open source e-commerce package that can be integrated relatively easily with Processwire, that would be nice.
  3. Since I first rebuilt this site in Processwire, it's had a major overhaul, with all competition data now handled on the site rather than in a separate desktop database app. Members are able to access the admin, but using AdminRestrictBranch, some hooks in ready.php and some custom process modules, logged in users are taken to a dashboard that varies depending on their role, so members can only see their own competition images (in a list via Lister Pro) and submit more, while the competition administrator has a dashboard that allows them to manage all aspects of competitions. Competitions close off automatically once their closing date has passed. CustomUploadNames module is used to automatically rename image files when they are uploaded so that once competition entries are downloaded as a zip file, they can be identified by filename. On the front-end slideshows are generated automatically once competition results have been entered, which is done via Lister Pro.
  4. It's possible to hide the page tree, and redirect users on login to some other page. Lister Pro allows you to create your own pages that show data in custom table layout that are editable, and it's not too hard to create your own admin dashboard module with links to several listers. Here's a thread with some discussion of both:
  5. ListerPro extends the Lister class, so it's a superset of functionality of Lister, so any bugs in Lister probably also apply in ListerPro. API reference for both is here: https://processwire.com/api/ref/process-page-lister/ I've found the upgrade to ListerPro well worth it, however if you're prepared to write your own modules some of the things it provides like saved lister layouts can easily be achieved with Lister, with minimal coding. I've used ListerPro to export (to CSV), but not to import. I wonder if the issue here is that has_parent is referring to the page id field rather than the title?
  6. An SQL "expert" with records with duplicate keys? That starts alarm bells ringing for me. Generally any SQL table should have a primary key which by definition must be unique for each record. Of course it's possible they have some sort of composite key based on multiple fields that needs combining to correspond to a unique page name in ProcessWire. There are certainly cases where I've build SQL tables with composite keys, with one scenario being many-many relationships, and that's something that Processwire doesn't handle too well, although there is a module that makes many-many type relationships possible, although it doesn't compare to what you can do with pure SQL. Processwire does handle One-Many relationships fine via page reference fields or Pagetable fields. If you really must have a direct relationship between SQL commands and table structure and your CMS, I actually wonder whether ProcessWire is your best option. I've been doing a bit of investigation of Directus which looks promising, although it's headless, so no templates for output like ProcessWire, just a REST API, from what I can see, no full text indexing, and being more of a direct SQL - CMS mapping, it also lacks the hierarchical parent-child structure that ProcessWire handles so well, as it doesn't make any assumptions about what sort of data structures you have, whereas ProcessWire, while generally very un-opinionated does treat everything as a page in a page hierarchy. For websites, that's generally a pretty reasonable assumption, but if you really don't want that, and just want pure SQL tables then there are alternatives. While something like Directus will give you a direct SQL to CMS mapping, it won't fix bad SQL data, so if you've already started down the ProcessWire path, you want to be really sure it's worth the effort to change. I come from a pure SQL background myself, and it only took me about 20 minutes of reading the ProcessWire documentation to understand how it works, so I don't think it should be hard for someone from an SQL background to adapt. Maybe there's room for a blog post or tutorial showing how to "do it this way in SQL" and ProcessWire equivalent along with what's different.
  7. Apart from working with ProcessWire, my other area of work is SQL databases, where I tend to have nearly all application logic contained in the database through views, stored procedures, user defined functions, triggers etc, so I understand how coming to ProcessWire can take some getting used to. If you simply want to import data from an existing system, then there's no problem to mix SQL queries in PHP and calls to the ProcessWire API to read data from an existing database using PHP's PDO or ODBC abstraction layers and then store fields to ProcessWire fields. I've done this myself before importing data from another system, and it's not overly difficult. Here's a bit of code I wrote a few years ago to import some data from another system into ProcessWire. Obviously the SQL will vary depending on what system you're importing from, and how you've named your ProcessWire fields will be different. This is old code, and untested, although I think it worked at the time. Having the Tracy Debugger module installed is a must have, as it provides a PHP console with code completion for the ProcessWire API, so that you can run ad-hoc bits of PHP code to do stuff like importing data without having to write a module or embed it in a template if it's just one off code that will only be run once. $webpressiondb = new PDO('mysql:host=127.0.0.1;dbname=mol_webpression', $user, $pass); $sql = "SELECT {$site}_docs.docid, {$site}_docs.parentid,custhead, subindex, title, keywords, author, {$site}_docs.modified, created, wbdesc, name, content, template, folder FROM {$site}_docs INNER JOIN {$site}_pages ON "; $sql .= " {$site}_docs.docid = {$site}_pages.docid ORDER BY {$site}_docs.subindex"; $wbdocs = $webpressiondb->query($sql)->fetchAll(); foreach ($wbdocs as $record) { //Need to allow for old records with no title. if (preg_match("/[a-zA-Z0-9]/i", $record['name'])) { print '<h1>' . $record['title'] . '</h1>'; $pwpage = new page(); $pwpage->parent = $pages->get($parent); $pwpage->template = $templates->get("rosina"); $pwpage->title = $record['name']; $pwpage->text3 = $record['title']; $pwpage->text1 = $record['wbdesc']; $pwpage->keywords = $record['keywords']; $pwpage->textHtml1 = $record['content']; $pwpage->wid = $record['docid']; $pwpage->wparent = $record['parentid']; $pwpage->worder = $record['subindex']; $pwpage->wcreated = $record['created']; $pwpage->wmodified = $record['modified']; $pwpage->custhead = $record['custhead']; $pwpage->save(); } } If you have cases where you really need traditional SQL tables with multiple fields in ProcessWire, you can create your own custom fieldtypes to do this, but you need to think carefully about whether you need this. The ProcessWire approach can be slow at bulk inserts, as each field results in a database INSERT statement, however retrieving data, especially if you don't need all fields is fast as it doesn't need to load fields in a query if you don't use them. If you're going to be doing a lot of multiple field inserts on an ongoing basis, and you're also going to want to retrieve most or all of the fields when you read the data, creating a custom fieldtype that's a traditional SQL table might give you performance advantage, but to date, I've generally found I've been able to work within ProcessWire's way of doing things.
  8. @adrian Thanks, that's working as expected again now.
  9. I'm having an issue with PW 3.0.163 and this module 1.1.12 where the initial option to send welcome message is not present, however the 'Re-send welcome message' option is present after saving a user. I think I used an earlier version of the module that didn't require the user to have the permission edit-profile, and that worked OK. I think the permission profile-edit is not being set until after the user is already published, so the initial option to send the welcome message is never shown.
  10. I've been running MariaDB 10.2 on CentOS with Plesk for a while, and I don't think I recall any issues.
  11. I've just noticed an issue thats cropped up before in other modules: Processwire allows mixed case field names, however they are always converted to lowercase in mySQL. If you use a mixed case field name eg in addColumns(['mixedCase']) you will get an SQL error, but if you do addColumns('mixedcase') you get no error, but a column of data with Field Not Found as contents. Changing this line in Rockfinder3.module.php seems to fix it: // add this column to columns array $colname = (string) strtolower($column); I'm about to see if I find any other instances.
  12. 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.
  13. 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.
  14. 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.
  15. @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.
  16. 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:
  17. 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?
  18. 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.
  19. 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.
  20. You could use PHP output buffering to read your file into a variable. Something like: ob_start(); include('./emailbody.inc'); $emailBody = ob_get_clean();
  21. 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.
  22. 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.
  23. 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. ๐Ÿ˜Š
  24. 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.
ร—
ร—
  • Create New...