Jump to content

bernhard

Members
  • Posts

    6,674
  • Joined

  • Last visited

  • Days Won

    367

Everything posted by bernhard

  1. this tool looks interesting! what are you building here? a pw module? or an online service?
  2. I got a promising response by the Intelephense developer: https://www.jetbrains.com/help/phpstorm/ide-advanced-metadata.html#override Does anybody know how to do that?
  3. Thx @teppo that helped a lot already Did you try that? It does not have any effect at all for me... The only way I got that working is changing the return hints of the wire() method in wire.php // from this @return ProcessWire|Wire|Session|Page|Pages|Modules|User|Users|Roles|Permissions|Templates|Fields|Fieldtypes|Sanitizer|Config|Notices|WireDatabasePDO|WireHooks|WireDateTime|WireFileTools|WireMailTools|WireInput|string|mixed // to that @return ProcessWire |mixed But that is really ugly and incorrect of course. @ryan do you have any ideas what ProcessWire could do about that "problem"? Or would it be better to ask the Intelephense developer for help to support multiple return types in the @return hint? Maybe it should just return the first listed class by default or maybe it should list all listed classes and all derived methods? I've created an issue to ask at Intelephense as well: https://github.com/bmewburn/vscode-intelephense/issues/1800 The wire property already returns the ProcessWire class correctly. But if wire() is used as the new standard I'd prefer to make that work on my setup and start using it in my own modules as well.
  4. Thx Ryan, I knew about the extra hop, but didn't know about the fuel thing. Nevertheless $this->wire()->... is no option for me at the moment, because I simply don't get any suggestions while $this->wire->... does bring me everything I need. Does anybody reading this know how to make VSCode recognize $this->wire() calls? Maybe I'm just missing a setting in Intelephense or maybe we are just missing some typehints in the core where PHPStorm is clever enough to work while VSCode is not? Thx
  5. v0.0.63 Thx to the feedback of @wbmnfktr I've made it a lot easier to get started with RockMigrations! The readme has now a dedicated quickstart section: https://github.com/BernhardBaumrock/RockMigrations#quickstart The example that was shipped with RockMigrations was also improved. I removed some complexity and used real world example names (a simple blog setup) instead of "foo" and "bar". This should make it a lot easier to understand ? Also I improved the page name replacements feature introduced lately: Page name replacements now ship with the module. They are saved in a dedicated folder and named "de.txt" for german replacements. If you need any other replacement options just let me know! (maybe @apeisa ? ) $rm->setPagenameReplacements("de"); https://github.com/BernhardBaumrock/RockMigrations/tree/master/replacements
  6. Not sure about performance, but I'm always using $this->wire->... because this supports intellisense while the other variants do not (in my setup): $this->wire->... correctly suggests the class properties and methods: $this->wire('files')->... does not: I guess $this->wire needs an extra call of the magic getter, but I have no idea if that really matters?! Whereas having intellisense matters a lot for me in my daily work...
  7. Nice, @Zeka I was curious and tried that out ? $langIds = []; foreach($languages as $lang) $langIds[] = $lang->isDefault() ? '' : $lang->id; $field = "title"; $field = "$field.data".implode("|$field.data", $langIds); db($field, 'field selector'); db($pages->find("template=person,$field*=schön")->each('title'), "search 'schön'"); db($pages->find("template=person,$field*=beautiful")->each('title'), "search 'beautiful'");
  8. I've opened a request issue for my idea above: https://github.com/processwire/processwire-requests/issues/400 If you like that idea please show your interest by giving it a thumb up, thank you ?
  9. This is just a quick info that I've built a little module on top of @David Karichs great PageHitCounter to store and present historical data of page views. Note that "historical data" means it can display all pageviews from the time this module has been installed. It can NOT show statistics from before that point of time! It is by no means meant to replace a full analytics software, but for simple sites this might be just what you (or the user) need(s). I release it as imperfect as it is for two reasons: Even if the presentation of the data is not perfect yet it might make sense collecting statistics sooner than later. If anybody wants to work on the presentation side I'd happily merge PRs (or if anybody wants to sponsor updates... PM) Presentation is done by plotly.js in conjunction with the awesome tabulator.js (both loaded via CDN at the moment) - that means easy analytics can already be done by using tabulator's internal filter capabilities! Please see the readme for important notes! https://github.com/baumrock/RockHitCounter
  10. Genius ?? Thank you!! I've created a PR @David Karich https://github.com/FlipZoomMedia/PageHitCounter/pull/9
  11. This is what I am using: $this->wire->addHookAfter('ProcessPageEdit::getSubmitActions', function($event) { $page = $event->process->getPage(); if($page->template != "foo") return; $actions = $event->return; unset($actions['next']); $actions['clone'] = [ 'value' => 'clone', 'icon' => 'clone', 'label' => 'Save + create copy', ]; $event->return = $actions; }); $this->wire->addHookAfter('ProcessPageEdit::processSubmitAction', function($event) { $action = $event->arguments(0); // action name, i.e. 'hello' $page = $event->process->getPage(); // Page that was edited/saved if($page->template != 'foo') return; if($action === 'clone') { $copy = $this->wire->pages->clone($page); $copy->title .= ' (copy ' . uniqid() . ')'; $copy->save(); $this->wire->session->redirect($copy->editUrl); } });
  12. I'm using PageHitCounter module by @David Karich The problem is that the page hit labels show up in my pagelistselect and when I select a page, the label of that page is "123 My Page" instead of "My Page" (where 123 is the page hit count). PHC attaches a hook to getPageLabel so I wonder if there is a way to determine if the render happens inside a pagelistselect field or not. $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListHitCounter'); Doing it via CSS does not work unfortunately, because I can hide the hit counter in the page tree, but selecting the page will show the count nevertheless because it is using js text() which does not take the display:none into account I guess. Any ideas?
  13. It's all in the docs: Then simply use the path of the pdf as path of the attachment: $file = $pdf->save(); $mail = new WireMail(); ... $mail->attachment($file->path); $mail->send();
  14. https://processwire.com/api/ref/wire-mail/attachment/
  15. v0.0.56 Today I had some troubles migrating field labels. Changes simply did not show up on the related page edit screen... turned out that some field setting overrides have been activated! Removing them via API is not that simple, so I added the feature to RM: ?
  16. See the link "afraid of hooks" in my sig ?
  17. Or a simple hook to modify the page edit form ? <?php $wire->addHookAfter("ProcessPageEdit::buildFormContent", function($event) { $page = $event->process->getPage(); if($page->template != 'yourtemplate') return; $form = $event->return; $f = $this->wire(new InputfieldMarkup()); $f->label = 'Help'; $f->icon = 'picture-o'; $f->value = "<img src='https://via.placeholder.com/350x150'>"; $form->insertAfter($f, $form->get('title')); });
  18. There are many ways ? What are you trying to do exactly and why? This helps finding the best solution ? Welcome to the forum btw!
  19. @adrian I'd ask you to rethink recommending AOS for such simple tasks as adding scripts to the admin. I know you are a big fan of it, but the only reason I see for using AOS or ACF is if you don't know how to place a hook to your system. But if you are able to do that, it is a lot better to copy a 4line hook than adding another dependency to your site. The hook will likely work without any problems for several years... AOS is already unmaintained and has introduced problems to several of my sites that where quite hard to find... It would be even better of course to put that hook into a dedicated simple module that does everything that the injected script is for ?
  20. Why not just add the file via hook? https://processwire.com/talk/topic/20725-add-possibility-to-prepend-or-append-scripts-and-stylesheets-in-admin/?do=findComment&comment=211800 $wire->addHookBefore('AdminTheme::getExtraMarkup', function (HookEvent $event) { $config = $this->wire->config; $url = $config->urls("MyModule"); $config->scripts->add($url."tabulator/js/tabulator.min.js"); $config->styles->add($url."tabulator/css/tabulator.min.css"); });
  21. v0.0.53 It always annoys me not to have the correct page name replacements for german umlauts...
  22. If using subdomains is an option I think it would be easier to serve the blog from blog.example.com
  23. If you are new to hooks this mini-tutorial might be helpful: https://processwire.com/talk/topic/18037-2-date-fields-how-to-ensure-the-second-date-is-higher/?tab=comments#comment-158164
  24. Thx. But how do I integrate them in my project (for testing and playing around with the chart.js samples)? My javascript level is unfortunately not the best, so I'm overwhelmed by all those new module/import/export stuff and how to use it ?
  25. @fedeb Very interesting, thx for sharing! ? @ryan Wouldn't it be great to abstract all that findings/knowledge into the files API? Importing data from CSV is a quite common need and thinking about all the pieces (like utf8 encoding, wrong delimiters etc) can be tedious and does not need to be ? $file = "/my/large/file.csv"; $tpl = $templates->get('foo'); $parent = $pages->get(123); $options = [ 'delimiter' => ',', 'length' => 100, 'firstLineArrayKeys' => true, ]; while($line = $files->readCSV($file, $options)) { $p = $this->wire(new Page()); $p->template = $tpl; $p->parent = $parent; $p->title = $line['Foo Column']; $p->body = $line['Bar Column']; $p->save(); } Support this request on github: https://github.com/processwire/processwire-requests/issues/400
×
×
  • Create New...