Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Craig last won the day on January 4 2016

Craig had the most liked content!

Community Reputation

555 Excellent

About Craig

  • Rank
    Distinguished Member

Profile Information

  • Gender
  • Location
    Gateshead, UK

Recent Profile Visitors

9,488 profile views
  1. Hi there, thanks so much for working as hard as you have been/still are on this module! I'm testing it out at the moment, and have come up against the error that was previously reported: Having dug into the code, I think I found the cause. My test PW installation is in a subdirectory - not its own host - and snipWireRootUrl returns the full path include the folders: /misc/pw-snipwire/processwire/setup/snipwire/ In the installer, as this variable is only used to set the parent page for custom-cart-fields, could ExtendedInstaller.php be updated to use the path instead of full URL? I updated it like this, re-installed, and it worked: // In ExtendedInstaller::__construct(): $this->snipWireRootPath = rtrim($this->wire('pages')->findOne('template=admin, name=snipwire')->path, '/') . '/'; // in _installPage(): // Page "parent" key may have "string tags" $parent = \ProcessWire\wirePopulateStringTags( $item['parent'], array('snipWireRootPath' => $this->snipWireRootPath) ); // In SystemResources.php 'parent' => '{snipWireRootPath}',
  2. We've all been there πŸ˜‰ Thanks for your perseverence on this! πŸ™‚
  3. Just wanted to let you know that I just tried this. It failed to log in as 'Craig A Rodway', so changed my name on the forum to just 'Craig' and it worked fine πŸ™‚
  4. Another loose approach to MVC like the last few posts above, is how I usually do things. Pages API is the model, template files are controllers, and separate files for views: <?php namespace ProcessWire; // templates/home.php region('breadcrumbs', false); region('content', wireRenderFile('views/home/hero')); region('content+', wireRenderFile('views/home/testimonials')); region('content+', wireRenderFile('views/home/benefits')); $meta['name']['twitter:description'] = $settings->site_tagline; $meta['property']['og:description'] = $settings->site_tagline; <?php namespace ProcessWire; // templates/register.php require_once("./_forms.php"); $status = processRegisterForm(); if ($status && $status['success']) { wire('session')->redirect($page->url . 'success/'); } $view = [ 'status' => $status, ]; if (wire('input')->urlSegment(1) == 'success') { region('pageTitle', 'Registration complete'); $page->summary = ''; $viewName = 'views/register/success'; } else { $viewName = 'views/register/form'; } region('content', wireRenderFile($viewName, $view)); wireRenderFile() is an alias of the PW Files API 'render' function and takes a path to a file and an optional array of data/variables. I also use the Markup Regions functionality. The examples above are taken from this GitHub repo for one of my sites.
  5. Great! The best location will depend on your circumstances and how you're directing unauthenticated users to the site. I typically create a single SSO endpoint - like /sso/. In PW land this would be an 'sso' template with the template file contents having the above code, then a page named 'sso' using that template. Then you can point people to example.com/sso/?token=eyJhbGciOiJIUzI... and have the generated token in the query string. It will log them in, and then you can redirect them to the homepage, or other desired content. If you're not pointing people to a specific SSO page - and instead just directing them to the site with the token in the query string - you definitely want to catch this as soon as possible. Using the _init.php file prepended to every template is one of several good places to put it, but you could also create a hook (like in site/init.php or site/ready.php) as well, but not sure (without testing) which methods I'd want to hook. Using either of those approaches, I'd also wrap the code in a function you can call from them to keep it tidy and/or reusable - check for the token - if present, validate and log them in; if not - just do nothing.
  6. Hi Orkun! I use the Firebase PHP JWT library when I need to use JWTs, and I would do it like this with PW: use \Firebase\JWT\JWT; // http://example.com/sso/?token=eyJhbGciOiJIUzI... $token = wire('input')->get('token'); // If not token, show error? $key = 'ABC123'; // Store/load your key somewhere (e.g. PW's $config var) try { $decoded = JWT::decode($token, $key, array('HS256')); } catch (\Exception $e) { // Error parsing/decoding token - do not accept. Show error/redirect. } // print_r($decoded); // Find user based on supplied email. // Use other PW user fields or properties from JWT as necessary. $u = wire('users')->get('email=' . wire('sanitizer')->selectorValue($decoded->email)); if ( ! $u->id) { // Could not find user - don't exist. // Could create them at this point, if you have enough detail in the JWT to do so. } // Force user login wire('session')->forceLogin($u); // Go to another page (don't stay on this one) wire('session')->redirect('/');
  7. I think this is a great addition! I made something similar a while ago (called Widgets) but it wasn't as thorough, simple, or effective as your Component implementation. I look forward to trying it out πŸ™‚
  8. I've been working with CodeIgniter for over 10 years, and although the general framework structure is predictable and documented, the custom code and database layout that has been developed with it could be... anything! You don't really have to learn it, but being aware of how it works might be useful in extracting the bits you need. I think these two documentation pages will be most helpful at this stage: https://codeigniter.com/user_guide/overview/appflow.html https://codeigniter.com/user_guide/overview/mvc.html As a rough guide, the URL patterns (/foo/bar) of a CodeIgniter app usually map directly to controllers. These should be in the application/controllers directory, and each file in here is a class. The example URL route of /foo/bar would call the bar() function in the Foo.php controller. Within the controller, it should (might!) call some 'models' - responsible for database interaction - and pass the result data into the 'views'. The views are responsible for transforming the data and results into HTML code that is sent to the browser, so this is likely where the main page layout should be, along with the different code for producing the different lists and detail pages. These live in the application/views folder. By default, there's no templating language or library used (like Twig) - the views are just mixed HTML and PHP, like ProcessWire, so should hopefuly be easy enough to follow. In terms of the database, you will need to look at how the current one is set up. With any luck, you could probably map each database table (books, movies, events) into PW templates of the same name, and set up PW fields that correspond to the columns in the database tables. After that, you would need to address any relationships or links between the tables or records, and decide on which PW structure will be best. For example, parent/child pages, Page reference fields, or creating a tagging/categories setup. If there's any budget for the project, I have some time over the coming weeks and would be happy to help you in the right direction if you think it would be useful πŸ™‚ Craig.
  9. @ryan Just submitted a site to the showcase on the new site, and the redirection took me to /sites/thanks/ - but this shows a 404 at the moment. πŸ™‚
  10. Hi all! Happy New Year πŸ™‚ I recently rebuilt the website for classroombookings - my open-source room booking system for schools - using PW πŸ™‚ classroombookings.com I started the project itself way back in about 2006, when I was working in a school and needed a solution. Over the years I haven't made that many changes to it - mostly due to lack of time - but it has a modest userbase. Fast-forward to late 2018 when it required a major update to support PHP 7, fix some issues, and I also launch a hosted service. The website serves marketing, documentation and download/release functions for the project and I think PW is ideal for it. In the spirit of open source, the code for the website is also available on GitHub for anyone who wants to poke around and see my approach to PW web builds. The site is pretty standard, the only 'custom' bit is the releases section, which it pulls from GitHub using their API and creates/updates pages (Releases module). The frontend uses the Spectre CSS framework, and this is the first site I've built using it. Modules: AdminTemplateColumns ProcessDateArchiver SettingsFactory TextformatterHannaCode
  11. Looks brilliant πŸ™‚ Win 10 Firefox - whole page screenshot. The only thing off is the Docs menu is still opening to the right and appearing off-canvas as mentioned elsewhere in the thread.
  12. Ha πŸ™‚ Being a Windows user, I get Segoe UI when it's used, and I quite like it and prefer it over Arial. I have noticed some slight vertical alignment things but it doesn't bother me that much.
  13. Have you thought about not using any webfonts at all, and instead use the native or system CSS font stack? Doing this removes any cross-browser/device font rendering issues as well as removing several external resources (smaller download + even faster loading!) There seems to be a shift towards this: https://booking.design/implementing-system-fonts-on-booking-com-a-lesson-learned-bdc984df627f http://markdotto.com/2018/02/07/github-system-fonts/ https://make.wordpress.org/core/2016/07/07/native-fonts-in-4-6/ Other resources: https://woorkup.com/system-font/ https://css-tricks.com/snippets/css/system-font-stack/
  • Create New...