Jump to content

bernhard

Members
  • Posts

    6,674
  • Joined

  • Last visited

  • Days Won

    367

Everything posted by bernhard

  1. Little tweak that you can add to your config.php on DEV to support bootstrapping of PW (in that case there is no SERVER_NAME set and you need to define it manually): <?php if(!defined("PROCESSWIRE")) die(); // make bootstrapping possible $const = get_defined_constants(true); $host = $const['user']['host'] ?: $_SERVER['SERVER_NAME']; $config->dbUser = 'root'; $config->dbPass = ''; $config->httpHosts = [$_SERVER[HTTP_HOST]]; $config->debug = true; switch($host) { case 'www.foo.bar': $config->dbName = 'foo'; $config->userAuthSalt = 'bar'; break; } Then you can execute any script like this: <?php namespace ProcessWire; define('host', 'www.foo.bar'); include('index.php'); foreach($pages->find('limit=100') as $p) { echo $p->path . "\n"; }
  2. Just added support for sending variables to getByName() // RockTabulator grid setup, eg dogs.php $dogs = new RockFinder2(); $dogs->getByName('animals', ['type' => 'dog']); $grid->setData($dogs); // finder setup, eg animals.php if(!$type) $type = "cat|dog"; $rf = new RockFinder2(); $rf->find("template=$type"); return $rf; Also added a simple orGroups() method (see https://github.com/processwire/processwire-requests/issues/331? $rf = new RockFinder2(); // setup selector $selector = ['parent' => '/foo/bar']; if($from AND $to) { // show items that are not in the future $selector[] = ['date_start', '<', $to]; // show items that ended this year or not yet $rf->orGroup($selector, [ ['date_end', '>=', $from], ['date_end', '=', ''], ]); } ...
  3. I had some weird symbols in that file where the base64 encoded string was. No idea where they came from, but I will only investigate if the problem occurs again. Thx for your help!
  4. Added support for renaming templates (and related fieldgroups): https://github.com/BernhardBaumrock/RockMigrations/commit/fd465dc27e4f2e3982ed6669da0478df8addfd90 $newTemplate = $rm->renameTemplate('oldtemplate', 'newtemplate');
  5. Thx that helped! I just deleted the exceptions.txt logfile which had some base64 encoded string in it. I guess this was the culprit ?
  6. This has been discussed before. I'm not against it, but I'm also fine with using the module. It works reliably.
  7. +1 Your clients might also find this helpful:
  8. Translations got even easier in RockTabulator:
  9. Think that would be a job for @Gadgetto ?
  10. @adrian any idea what could be the cause for this: Error in ProcesswireLogsPanel ProcessWire\WireException: Unable to encode array data for cache: TracyLogData.ProcessWire in C:\www\xxx\wire\core\WireCache.php:450 Stack trace: #0 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\panels\ProcesswireLogsPanel.php(44): ProcessWire\WireCache->save('TracyLogData.Pr...', false, '2010-04-08 03:1...') #1 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-2.6.x\src\Tracy\Bar\Bar.php(147): ProcesswireLogsPanel->getTab() #2 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-2.6.x\src\Tracy\Bar\Bar.php(121): Tracy\Bar->renderPanels('') #3 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\tracy-2.6.x\src\Tracy\Bar\Bar.php(97): Tracy\Bar->renderHtml('main') #4 C:\www\xxx\site\assets\cache\FileCompiler\site\modules\TracyDebugger\TracyDebugger.module.php(1713): Tracy\Bar->render() #5 C:\www\xxx\wire\core\Wire.php(383): TracyDebugger->sessionHandlerDBAjaxFix(Object(ProcessWire\HookEvent)) #6 C:\www\xxx\wire\core\WireHooks.php(917): ProcessWire\Wire->_callMethod('sessionHandlerD...', Array) #7 C:\www\xxx\wire\core\Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessWire), 'finished', Array) #8 C:\www\xxx\wire\core\ProcessWire.php(609): ProcessWire\Wire->__call('finished', Array) #9 C:\www\xxx\wire\core\ProcessWire.php(505): ProcessWire\ProcessWire->__call('finished', Array) #10 C:\www\xxx\wire\modules\Process\ProcessPageView.module(258): ProcessWire\ProcessWire->setStatus(16) #11 C:\www\xxx\wire\core\Wire.php(380): ProcessWire\ProcessPageView->___finished() #12 C:\www\xxx\wire\core\WireHooks.php(813): ProcessWire\Wire->_callMethod('___finished', Array) #13 C:\www\xxx\wire\core\Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessPageView), 'finished', Array) #14 C:\www\xxx\index.php(56): ProcessWire\Wire->__call('finished', Array) #15 {main} Latest version. Error seems to occur only on windows (but not sure).
  11. wire()->addHookAfter('Pages::saveReady(template=articolo,in_evidenza=1)', function($event) { $reset = $this->pages->find("in_evidenza=1"); foreach($reset as $p) $p->setAndSave('in_evidenza', 0); });
  12. Not sure if there's a better way but this should work: $wire->addHookAfter("Inputfield::render", function($event) { $field = $event->object; $id = (int)str_replace('repeater_item_', '', $field->name); $page = $this->pages->get($id); });
  13. That looks very similar to my version, didn't know about your script! I'd love to have a module that handles that properly...
  14. https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/#using-internal-components-modules
  15. See here: https://github.com/BernhardBaumrock/tabulator.test/blob/837d509f1ef6816fe3629c163bd66d53c5e39209/site/ready.php#L31-L73 That's exactly doing what you are looking for but also creates a ZIP of the sql (which reduces size drastically). It also comes with a restore script: https://github.com/BernhardBaumrock/tabulator.test/blob/master/site/assets/mysqldump/restore.php This is the first time I'm using it, so it's not well tested and some parts are hardcoded (eg tabulator.sql / tabulator.zip). But it should get you going. I created this because the pw internal dump takes ages to restore ( for @dragan it took several hours? ). My workflow: logout commit changes push changes
  16. Added a new example how to add and hide columns via JS:
  17. VSCode makes working with git a breeze and now that github has unlimited private repos it's really great combination! https://code.visualstudio.com/Docs/editor/versioncontrol https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens
  18. I think that's the best solution and I can't think of any problems using it ?
  19. And how would i log that to the console when the panel is closed? I'll file an issue on github for a little change that the events are triggered on the toggling element instead of $(document) - I think that would be the best solution. Thx for your help! Please give the issue a thumb up: https://github.com/processwire/processwire-issues/issues/975 Then triggering the grid reload is as simple as this: $(document).on('pw-panel-closed', '.rt-reload', function() { RockTabulator.getGrid(this).reload(); });
  20. Yes, if I'm not missing anything: https://github.com/processwire/processwire/blob/master/wire/modules/Jquery/JqueryUI/panel.js#L387 Actually that's my own fault ? ? https://github.com/processwire/processwire/pull/107
  21. The href attribute is there for a reason: I'm developing RockTabulator and a comman scenario is having a button to add new pages on top of the grid. I want this button to open the page edit screen of the newly created page in a pw-panel. And I want it to support middle-clicks to open the link in a new tab (that's why I need the href attribute and the data-href alone is not enough). So far, so good (and easy). But pw-panel does not offer a way to check which element triggered the opening of the panel. So I wanted to create a workaround that does the following: When a link/button having class "rt-panel" is clicked, open a pw-panel and (and that's what differs from pw-panel) when this panel is closed, reload the corresponding grid. pw-panels have the "pw-panel-closed" event, but I know nothing about the triggering element. So if I had 3 grids with one "add new ..." button each, I'd have to reload all 3 grids even if a page was only added to one grid (and only this grid should get reloaded). That's why I wanted to intercept the click on the link, add the triggering element to the panel element (as data-toggle or whatsoever) and whenever a pw-panel is closed check for the triggering element, get the grid and fire the grid.reload() Hope that makes things clearer. Maybe a request to change the implementation of pw-panels would make more sense. Just wanted to know if I'm missing something totally obvious ? PS: I could use a regular links as well, but I'm creating buttons in the backend (via PHP) and the syntax for InputfieldButton fits best: $button->addClass('foo bar'); $button->icon('plus'); ... Am I missing a good way of creating simple links that look like buttons that way? Not sure about using InputfieldSubmit - I have to think about that...
  22. It might be easier to add a button via this hook to try it yourself: /site/ready.php $this->addHookAfter("InputfieldText::render", function($event) { $field = $event->object; if($field->name != 'title') return; /** @var InputfieldButton $b */ $b = $this->wire->modules('InputfieldButton'); $b->href = 'https://www.processwire.com'; $b->attr('data-href', $b->href); $b->value = 'pw.com'; $script = '<script>'.$this->files->render(__DIR__ . '/button.js', [], [ 'allowedPaths' => [$this->config->paths->site], ]).'</script>'; $event->return .= $b->render().$script; }); /site/button.js alert('loaded'); $(document).on('click', 'a', function() { alert('click'); return false; });
  23. Hello everybody, got stuck on a supposed simple thing: I want to intercept a click on a button that is rendered in the backend from InputfieldButton::render(); The button code is wrapped around an anchor tag because I set the HREF attribute: <a class="InputfieldButtonLink" href="..."> <button class="... rt-panel" name="button" value="..." type="button" data-href="..."> <span class="ui-button-text"><i class="fa fa-plus"></i> Add something</span> </button> </a> I can't seem to find a way how I can prevent PW from opening this link ? The reason why I want to do this is that I need to modify the behaviour of the internal panel. $(document).on('click', 'a.InputfieldButtonLink', function(event) { var $el = $(event.target); alert('clicked'); return false; }); It shows the alert but it also reloads the page, which is not what I want! Outside of PW this works fine: https://jsfiddle.net/baumrock/npvzk6t7/1/ Any ideas? Thx!
  24. Just finished and pushed support for rowactions: Now you can add actions to any row of your grids easily. Easy reload of the grid after something changed and even adding actions on the fly (JS-only) is easy:
×
×
  • Create New...