Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/15/2025 in all areas

  1. This week we’ve got 2 new versions out: 3.0.246 on the main/master branch, and 3.0.247 on the dev branch. Version 3.0.246 (main/master) contains several minor bug fixes that were discovered after 3.0.244. And 3.0.247 on the dev branch adds support for conditional hooks that can match method return values. The hooks documentation has been updated with a new section that covers all the details here. I’m going to slow a bit on core updates over the next few weeks so that I can dedicate more time to developing the new ProcessWire website. The designers have done a great job and now I need to focus on getting some parts of it developed and new text written, etc. I’ll keep you up-to-date as it moves forward. Thanks for reading and have a great weekend!
    7 points
  2. @ryan, is there any difference in terms of performance between using conditional hooks and doing the equivalent logic of checking the arguments and/or return value within the hook and returning early when a condition is not met? Personally I've preferred not to use the conditional hook syntax because I find it more readable to have PHP logic in the hook code, but if this was less performant I'd consider changing.
    4 points
  3. Hi everyone! I've started working on a new module that contains development tools like asset minification. Why a new module when RockFrontend and RockMigrations already have similar features? I wanted to start fresh to make the code cleaner, and most importantly make it work properly with template cache! The old implementation in RockFrontend using page render hooks simply couldn't handle that. The module is intended for development-only and should be disabled on production. The idea is to create minified assets while developing and then push the minified assets to production and there just include them in your markup! LiveReload has also been moved from RockFrontend to this module. It's simply not a frontend-tool but rather a development tool! Using RockMigrations, for example, I'm always using the LiveReload feature on the backend, so it does not really make sense to have it in the frontend module 🙂 Download & Docs: baumrock.com/RockDevTools
    1 point
  4. This hook is used to monitor file changes and page updates in your ProcessWire project. It operates when debug mode is active and returns file changes and latest page update information in JSON format. The script hook is automatically injected before the </body> tag in your HTML. It periodically checks for any file or page updates in your system at the interval you specify. If the previous check time is older than the new check time (indicating changes), the page automatically refreshes. ~/site/ready.php if ($wire->config->debug) { $wire->addHookAfter('Page::render', function (HookEvent $event) { $script = <<<HTML <script> const browserSync = { mtime: 0, init() { this.sync(); }, sync() { fetch('/browser-sync') .then(response => response.json()) .then(data => { if (!this.mtime) { this.mtime = data.max; } else { if (data.max > this.mtime) { location.reload(); } } }); } }; browserSync.init(); setInterval(() => browserSync.sync(), 2500); </script> HTML; $event->return = str_replace('</body>', "{$script}</body>", $event->return); }); $wire->addHook('/browser-sync', function (HookEvent $event) { $wire = $event->wire(); $root = $wire->config->paths->root; $siteRoot = $wire->config->paths->site; $extensions = '*.{php,js,css}'; $paths = [ "{$root}src/{$extensions}", // custom composer package "{$root}src/src/{$extensions}", // custom composer package "{$siteRoot}{$extensions}", // ready.php, init.php, finished.php "{$siteRoot}classes/{$extensions}", // page classes "{$siteRoot}templates/{$extensions}", "{$siteRoot}templates/*/{$extensions}", "{$siteRoot}templates/*/*/{$extensions}", "{$siteRoot}templates/*/*/*/{$extensions}", "{$siteRoot}templates/*/*/*/*/{$extensions}", ]; $files = []; foreach ($paths as $pattern) { // Try with GLOB_BRACE first $result = glob($pattern, GLOB_NOSORT | GLOB_BRACE); // If no results with GLOB_BRACE, try without it if (!$result) { $result = glob($pattern, GLOB_NOSORT) ?: []; } $files = array_merge($files, $result); } $filemtime = 0; foreach ($files as $file) { if (!is_file($file)) { continue; } try { $mtime = @filemtime($file); if ($mtime && $mtime > $filemtime) { $filemtime = $mtime; } } catch (\Exception $e) { continue; } } $latest = $wire->pages->get('sort=-created|-modified'); $latestTime = $latest->modified > $latest->created ? $latest->modified : $latest->created; header('Content-Type: application/javascript'); echo json_encode([ 'max' => max($filemtime, $latestTime), 'mtime' => $filemtime, 'modified' => $latest->modified, 'created' => $latest->created ]); exit; }); } This development tool helps streamline your workflow by automatically refreshing the browser when you make changes to your files or content, eliminating the need for manual page refreshes during development.
    1 point
  5. I apologize if I sounded rude in my first reply. It had been some years since I’d last worked with WordPress, when an academic friend asked me to help her migrate (and upgrade) her WP site last month to a new provider. This should have been a very straightforward job, but every single one of the plug-in authors had built in limitations that kept me from doing very simple things unless I upgraded to their pro-level versions — and in most cases this would have involved minimum one-year subscriptions. And since my client’s site had been hosted with a provider that allowed no command-line access and only limited SFTP, I was at the plug-in authors’ mercy. Your situation is quite different, of course, but the whole experience reminded me strongly of what I dislike about what WP has become. In my case, I can attest that PW is about 50% of my income, and that I devote about 50% of my work-time towards it, so it’s certainly a viable means of income. But it’s true that creative work, even in IT, is a less predictable income stream than maintenance. Best of luck with ProcessWire, and with going freelance! I hope we’ll continue to see you here in the forum!
    1 point
  6. @bernhard Yes, I know about it. However, I prefer not to use modules for these kinds of things, as my work approach would need to adapt to each module used. I am using Vite for these purposes instead. Before developing this script, I was using the AllInOneMinify module for ProcessWire. Later, I switched to JavaScript-based compilation solutions: First moved to Gulp with Browser Sync Then migrated to Webpack Currently using Vite Among these tools, Vite has proven to be the lightest solution, and I'm getting exactly the results I want with my Vite configuration. While using Vite, I wondered "Why don't I implement my own browser sync solution?" This led me to write this lightweight script, which works remarkably well. And I'm happy with this setup!
    1 point
  7. Hello everyone, I’m excited to share with you a project I’ve recently developed – a URL shortener site and profile. Github/Profile: https://github.com/mxmsmnv/site-lqrs Demo https://lqrs.org/
    1 point
  8. To get the options title in current user language use $type_material->getTitle(); or enable outputformatting $type_material->of(true); $type_material->get('title');
    1 point
×
×
  • Create New...