-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
Am I missing something obvious with my code? This does not work, neither addHookBefore not addHookAfter: // site/ready.php and also in init() of an autoload module bd('ready!'); $wire->addHookBefore('ProcessPageView::pageNotFound', function($event) { bd('test'); die('test'); }); It logs "ready" but does not fire the hook. I tried it in 2 different installations. Dumping bd('test') inside of pageNotFound() in ProcessPageView.php works, so the method get's executed but the hook never gets called?! ? @Robin S you've once told me that you hook the 404 page for some REST stuff, but I could not find that post any more. Thx for your help everybody ?
-
☁️ Duplicator: Backup and move sites
bernhard replied to flydev's topic in Module/Plugin Development
Hi flydev, just needed to use this module and didn't find that button until i found that I need to install the process module. In one of your screencasts there was the "event trigger" dropdown which is not there any more in newer versions. Why is the process module not installed on installation? I was looking under "setup" before installing the process module and there was of course no duplicator page until i found out that I had to install the process module manually. Maybe you could also add a hint on the duplicator config screen? Thx for you module! -
No, thanks, that's similar to what I was talking about and I have to try your module before I can make any further suggestions ? That was exactly what I was thinking of ? Thx for sharing the search link. I tried it using "test" as keyword. The result did not show "test" anywhere on the results page. I then clicked on https://wireframe-framework.com/docs/directory-structure/ and found "latest" there. That' exactly the things that are tedious when implementing site searches and that's why I'm really thankful that you built a module for it that we can improve step by step (and hopefully as community). I'll need your module on a project soon. Maybe I can contribute something then.
-
Thx Teppo, that module will be a great contribution! ? Maybe you could already think of different frameworks so that others can add default markup for different frameworks easily in separate folders? Maybe just define a path where the module should take files to render, then we could have some examples in the module itself, like /site/modules/SearchEngine/tpl/uikit/head|entry|foot.php or /site/templates/search/head|entry|foot.php
-
To be honest: I don't know. But I'd be happt to know it if some knows it or finds out ?
-
Creating thousands of pages via the API
bernhard replied to David Beesley's topic in API & Templates
Maybe you have some hooks that are causing this? Or a module that does some calculations? A default PW installation should not have any problems with several thousand pages... -
[solved] Weekend Challenge: Need help for my new Markup Module :)
bernhard replied to bernhard's topic in General Support
Thx, that was one part of the problem, but the actual problem was that I had the setLabel() method called in the render() method of the inputfield and that obviously didn't work on ajax fields. It worked in my ProcessModule because the label there was set manually (and it worked in your example because you also set a label in the field settings, thx for the video!). The latest version now fixes all those problems and I think this version is already quite useful. Next week I'll continue my work on RockTabulator which will be based on RockMarkup and if that all works well and does not need any further changes I'll officially release RockMarkup. Have a great weekend everybody ? Edit: This is a perfect example why I started building this module: In theory it's always easy to create custom markup anywhere in the admin by using hooks or creating little custom modules. But after time you change things, move fields or set them to AJAX and things break... The goal of this new module is that you don't have to take care about all that. Just paste some code and get reliable results ? -
Absolutely true! Thx for sharing! ? Are there any live examples of you module?
-
I'm close to releasing my new module called RockMarkup which will be similar to @kongondo's and @kixe's markup modules. The module is already on github and ready to play with: https://github.com/BernhardBaumrock/RockMarkup Unfortunately I have a bug that I can't seem to find. When a field is placed in a template and visibility is set to "closed + AJAX load" the field does not work at all: Would be great to get some help with this one! URL for installation of the module: https://github.com/BernhardBaumrock/RockMarkup/archive/master.zip
-
How to properly structure a complex membership system?
bernhard replied to WireCodex's topic in General Support
Short answer: RockFinder + RockGrid are exactly built for such tasks and RockTabulator is currently under development. You can PM me if you want to talk about possible collaboration/sponsoring/consulting. -
Abort module Uninstall on condition
bernhard replied to cosmicsafari's topic in Module/Plugin Development
This is what I came up with today: I have a main module that installs 3 other modules (via module info "installs" => ["mod1", "mod2", "mod3"]). Uninstall was a bit of a problem, because it tried to uninstall a fieldtype module and this was not possible when I had an existing field of that type. Throwing an exception did also not work, because all submodules where uninstalled even if the main module threw an exception. I then tried to throw an exception in all of the submodules as well, but that was a mess and did not work reliably. Hooks to the rescue: public function init() { $this->addHookBefore("Modules::uninstall", $this, "customUninstall"); } /** * Custom uninstall routine * * @param HookEvent $event */ public function customUninstall($event) { $class = $event->arguments(0); if($class != 'yourmodulename') return; // set flag $abort = false; // check1 if($this->check1() == false) { $this->error('check1 failed'); $abort = true; } // check2 if($this->check2() == false) { $this->error('check2 failed'); $abort = true; } // uninstall? if($abort) { // there where some errors $event->replace = true; // prevents original uninstall $this->session->redirect("./edit?name=$class"); // prevent "module uninstalled" message } } Real life example that also checks if the uninstalled module is the main module or a sub-module. If it is a sub-module it shows an error and redirects to the config screen of the main module: public function init() { $this->addHookBefore("Modules::uninstall", $this, "customUninstall"); } /** * Custom uninstall routine * * @param HookEvent $event */ public function customUninstall($event) { $installs = $this->getModuleInfo(); $class = $event->arguments(0); $url = "./edit?name=$class"; // exit when class does not match if(!in_array($class, $installs)) return; // intercept uninstall $abort = false; // if it is not the main module we redirect to the main module's config if($class != 'RockMarkup') { $abort = true; $url = "./edit?name=RockMarkup"; $this->error('Please uninstall the main module'); } // check if any fields exist $fields = $this->wire->fields->find('type=FieldtypeRockMarkup')->count(); if($fields > 0) { $this->error('Remove all fields of type RockMarkup before uninstall!'); $abort = true; } // on uninstall of the main module we remove this hook so that it does // not interfere with the auto-uninstall submodules if($class == 'RockMarkup') $event->removeHook(null); // uninstall? if($abort) { // there where some errors $event->replace = true; // prevents original uninstall $this->session->redirect($url); // prevent "module uninstalled" message } } -
How to pass all API variables to $files->render() ?
bernhard replied to bernhard's topic in General Support
Awesome! Exactly what I was looking for, thx ? Maybe also interesting for you @kongondo (or are you already using it like this in your module?) Thx for the idea @ukyo but I need that feature for backend development and I can't rely on the functions API and it's also only recommended for use on the frontend. -
I'm working on a new markup module and want to have the API available in the included file. I know I can do that: $code = $this->files->render('myfile', [ 'page' => $this->page, 'pages' => $this->pages, ... ]); Then I'd have $page and $pages in my file, but I'd need to list all available API variables manually and keep them in sync with the API. Other solution: $code = $this->files->render('myfile', [ 'that' => $this, ]); Then I'd have all API variables available from $that->page, $that->pages etc. Can I get best of both? Thx ?
-
https://devblogs.microsoft.com/commandline/take-your-linux-development-experience-in-windows-to-the-next-level-with-wsl-and-visual-studio-code-remote/
- 246 replies
-
- 2
-
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
RockSkinUikit - Easily and quickly skin your AdminThemeUikit backend
bernhard replied to bernhard's topic in Modules/Plugins
Why don't you just try that? ? -
RockSkinUikit - Easily and quickly skin your AdminThemeUikit backend
bernhard replied to bernhard's topic in Modules/Plugins
What file are you talking about? This one? https://github.com/BernhardBaumrock/RockSkinUikit/blob/master/themes/default.less It's the first 90 lines of AdminThemeUikit\uikit\custom\pw\pw-theme-reno.less with some custom modifications. -
RockSkinUikit - Easily and quickly skin your AdminThemeUikit backend
bernhard replied to bernhard's topic in Modules/Plugins
Correct ? Technically yes, but I guess you'd have to do a lot of customizations. Just give it a try and please report back your findings! -
I don't know it right now but maybe the page name is reset after that hook. Does it work using Pages::saved instead of ::save? I'm usually using saveReady or saved to hook ?
-
http://bfy.tw/OPbk Please provide some more information what you have tried so far, what worked, what did not work, where exactly you need help, what is the challenge/goal and so on.
-
Already in the works and making good progress ? Great 2 posts, @Robin S! Thank you for all your contributions and always positive and helpful comments. It's really great having you here! ?
-
Don't see anything bad with that. What strings do you want to be translatable? Never needed translatable strings in config ? Would ready.php be too late? Or a separate module's init()? You could also set $config->... = $this->_(...); there
-
Great, thank you ? Would be great if you could add an option to set markup of some popular css frameworks easily on your todo list as well ? eg $config->MarkupMenu = 'UIkit3'; // $config->MarkupMenu = 'Bootstrap4'; // ...
-
For creating screencasts you can use https://screencast-o-matic.com/home or https://www.cockos.com/licecap/
-
Modern IDEs make this really easy:
-
Creating thousands of pages via the API
bernhard replied to David Beesley's topic in API & Templates
I stopped at 200k, that's enough for my performance tests for now (RockTabulator) created 1000 pages in 52.123s, 0.052s per page, used 15.16 mb memory deleted 1000 pages in 5.759s, 0.006s per page, used 19.35 mb memory On my setup it would take 6*15 = 90seconds to delete 15k pages. Maybe you have some hooks running? That's always a pain and slowing down things when you need to modify huge amounts of pages... Code used: <?php namespace ProcessWire; $time_pre = microtime(true); include("../../../index.php"); // bootstrap ProcessWire function convert($size) { $unit=array('b','kb','mb','gb','tb','pb'); return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; } function showTime($time_pre, $num) { $time_post = microtime(true); $t = $time_post - $time_pre; $m = memory_get_usage(); echo "processed $num pages in " . round($t, 3) . "s, " . round($t/$num, 3) . "s per page, used " . convert($m) . " memory\n"; } $num = 0; foreach($pages->find('parent=/data,id>257975') as $p) { $p->delete(); echo "deleted $p\n"; gc_collect_cycles(); $num++; } showTime($time_pre, $num); return;