-
Posts
6,659 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
Just released v5.0.0 of RockFrontend LiveReload has been removed (moved to RockDevTools) styles() and scripts() feature has been removed (moved to RockDevTools) RockDevTools is unfortunately not a drop-in-replacement as we had to change how assets are handled and included into the final website markup. The good news is that RockDevTools also supports merging multiple files to one and it will also work with template cache enabled π
-
Imagine you have a multisite setup where you need different languages for different domains: One website might be single-language (DE only), another one might need DE/EN/CZ, and another one might need DE/EN/HU: I didn't know how to do it, and I didn't find any other posts with a similar need or solution. When looking into the code I even thought that my need was not possible yet without modifying a core file. So I asked Ryan if he was willing to make the process of adding languages to the $languages array hookable. Turns out that this is not necessary! All you have to do is to grab the Iterator of the languages array and remove languages as you need: // /site/ready.php if($anyCondition) { // remove CZ language $languages->getIterator()->remove("name=cz"); } So simple π Maybe it helps π
-
- 4
-
-
-
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
- 21 replies
-
- 10
-
-
Weekly update βΒ 8 March 2024 β New invoices site profile
bernhard replied to ryan's topic in News & Announcements
Anybody stumbling over this site profile might also be interested in my new RockInvoiceItems Fieldtype/Inputfield π -
Rock-Monthly Newsletter subscribers know that I'm rebuilding my custom CRM/bookkeeping software. It has already sparked two powerful new Rock modules! π RockInvoiceItems provides a powerful Fieldtype/Inputfield combo for handling invoice line items with real-time calculations, rich text editing, and a clean UI. Key Features: Dynamic line item management (add/delete/clone/sort) Rich text editing item descriptions with TinyMCE Automatic calculations (subtotals, VAT, grand totals) Multiple VAT rates support Drag & drop sorting Easy to use PHP API, eg $items->subtotal(), $items->grandtotal() German translations included The module extends WireArray and handles all the JSON serialization/deserialization behind the scenes. It's easy to install - just drop it in your modules folder and you're ready to go! Download & Docs: baumrock.com/RockInvoiceItems Let me know if you have any questions! π
-
- 5
-
-
How to handle responsive images in a blog with many images via TinyMCE?
bernhard replied to Krlos's topic in General Support
That's a valid question by the client. That's why I do not allow images in richtext fields. But there's never an "ideal approach". Everything has pro's and con's. -
How to handle responsive images in a blog with many images via TinyMCE?
bernhard replied to Krlos's topic in General Support
RepeaterMatrix and RockPageBuilder. There you don't add content to one WYSIWYG field but instead compose your blog content from predefined blocks where you have full control over the generated markup for each block and the client still has the flexibility to choose whatever blocks he/she needs. Similar to what @Robin S suggests if you are using RockFrontend that's already on board via Dom Tools. $dom = rockfrontend()->dom($page->your_wysiwyg_field); $dom ->filter("img") ->each(function (HtmlPageCrawler $node) { $newHTML = '...' $node->replaceWith($newHTML); }); echo $dom->html(); I'd highly recommend not to use images in richtext fields, though. -
Hooks inside init.php to namespaced classes does not work [SOLVED]
bernhard replied to Juergen's topic in API & Templates
It should not matter when/where you do it. The only thing that matters is that you attach your hook before you actually call the method that is hooked. If you call the method first and than add the hook it will obviously not return the hooked result but the plain result. -
Hooks inside init.php to namespaced classes does not work [SOLVED]
bernhard replied to Juergen's topic in API & Templates
I'd be interested, but I don't understand what you are saying. Neither what you said yesterday nor what you said today. What is "a class loaded directly on a page"? And what is "indirectly within a form" ?! -
Thx, will be added in the next version!
-
Hooks inside init.php to namespaced classes does not work [SOLVED]
bernhard replied to Juergen's topic in API & Templates
/site/init.php wire()->addHookAfter('Foo::hello', function ($event) { $event->return .= ' - hooked :)'; }); /site/modules/WhatEver/Test.module.php <?php namespace ProcessWire; use MyNamespace\Foo; class Test extends WireData implements Module { public static function getModuleInfo() { return [ 'title' => 'Test', 'version' => '0.0.1', 'summary' => 'Your module description', 'autoload' => true, 'singular' => true, 'icon' => 'smile-o', 'requires' => [], 'installs' => [], ]; } public function init() { wire()->classLoader->addNamespace('MyNamespace', __DIR__ . '/classes'); } public function ready() { $foo = new Foo(); bd($foo->hello()); } } /site/modules/WhatEver/classes/Foo.php <?php namespace MyNamespace; use ProcessWire\Wire; class Foo extends Wire { public function ___hello() { return "HELLO!"; } } -
Hooks inside init.php to namespaced classes does not work [SOLVED]
bernhard replied to Juergen's topic in API & Templates
I'm using namespaces all the time and it works for me when not adding the namespace on the hook. -
Hi @Pavel Radvan these kind of errors are easy to solve by searching the error message in google: https://www.google.com/search?q=class+domdocument+not+found&oq=class+domdocu&gs_lcrp=EgZjaHJvbWUqBwgAEAAYgAQyBwgAEAAYgAQyBggBEEUYOTIICAIQABgWGB4yCAgDEAAYFhgeMggIBBAAGBYYHjIICAUQABgWGB4yCAgGEAAYFhgeMgYIBxBFGDzSAQgzMDg4ajBqN6gCALACAA&sourceid=chrome&ie=UTF-8
-
Hey @herr rilke please use the new RockDevTools module for handling assets: https://github.com/baumrock/RockDevTools/tree/dev/docs/assets Due to several limitations and issues like you have found asset tools of RockFrontend will be removed in the next major version. Please mark this [solved] if everything works for you.
-
Attepting to Fetch Pages Based Off of Field Match in Latte Filter
bernhard replied to protro's topic in General Support
Could you share the exact code? As far as I understand your screenshots ProcessWire tries to call ->getShowByArtist() but doesn't find it and therefore tries to run Hooks, which is what it does to execute any methods that are attached via hooks and not really added to the class itself. The question is still why it doesn't find the getShowByArtist method when it should be there. In your case I'd search my codebase for "getShowByArtist" and make sure that it only exists at one single location. Then, I'd remove that call and replace it with a bd() call, for example bd($item). Tracy should then dump a "HomePage" object to the debug bar. If it dumps a different object, then it makes sense that it throws an exception that the getShowByArtist method does not exist. -
On the template settings of every template you can define whether this template defines access settings or not. If not, it inherits from the parent template. As page id=1 does not have a parent template it is required that the template set for page #1 has access settings enabled.
-
Agreed. When using Custom Page Classes + MagicPages these kind of things are super easy to do: <?php public function onCreate() { $this->mycheckbox = 1; } But a hook in /site/ready.php would also not be much more work. Just less beautiful in my opinion π <?php wire()->addHookAfter('Pages::saveReady', function($event) { $p = $event->arguments(0); if($p->id) return; if($p->template != 'whatever') return; $p->mycheckbox = 1; });
-
The problem with default yes is that it would not affect already existing items. So if you had 100 pages already, then you add a checkbox with default=1 and you add another 200 pages and then you use a selector "mycheckbox=1" then it would find 100 pages, not 200. Or you'd have to update all 100 pages that already existed before you added the checkbox. Ryan recommended once (if I remember correctly) to use what I'd call the reverse-label-pattern. So instead of showing a checkbox "send email after save" that is default on, you'd add a checkbox that is default off and shows "do NOT send an email after save". Or "no mail after send" or whatever. Or you add a hook on page create that populates the checkbox for you. Or you add a toggle field, that has the option to set default yes/no etc. I think I'd probably use a nice, non-reversed label together with a hook to auto-populate when the page is created.
-
@Spinbox thx for your report, but it would be nice if you could also try to add helpful information to your report rather than just a short "not working" note. Please try different browsers, etc.; Multi-Language yes/no etc.? Console errors? ...
-
Attepting to Fetch Pages Based Off of Field Match in Latte Filter
bernhard replied to protro's topic in General Support
Nice, looks a lot better no in my opinion π That sounds strange. I think the only explanation is that ->getShowByArtist() is called on a non-HomePage object. When it throws an Exception you should get a backtrace that you can in spect. Go through the list step by step and inspect which call triggered which next step. This list can be quite long, so I first focus on all files that are under my control and skip those from the core. TracyDebugger is usually really helpful here and you can even click on the line in the stack and land directly in your IDE at the right position. Hope that helps π -
This should work, see here: https://processwire.com/talk/topic/29593-solved-do-the-reset-password-tricks-work-for-you-they-dont-work-for-me/?do=findComment&comment=239355 It will log you in and redirect to the backend, so you'll also know the admin url then.