Jump to content

bernhard

Members
  • Posts

    6,671
  • Joined

  • Last visited

  • Days Won

    366

Everything posted by bernhard

  1. Hey @David Karich I wanted to install PHC + RHC today like this: <?php // install page hit counter $phc = $rm->installModule("PageHitCounter", "https://github.com/FlipZoomMedia/PageHitCounter/archive/refs/heads/master.zip"); if($phc) { $rm->setModuleConfig($phc, [ 'forTemplates' => [ 'home', 'basic-page', // blog Item::tpl, Overview::tpl, // teams TeamPage::tpl, PersonPage::tpl, ], // exclude roles from tracking 'forRoles' => [ 'superuser', 'webmaster', ], ]); $rm->installModule("PagePaths"); $rm->installModule("RockHitCounter"); } } This does ALMOST work. The problem seems to be that the "addCounterField" method does not get triggered when using RockMigrations compared to a manual module save: <?php // ------------------------------------------------------------------------ // On save actions // ------------------------------------------------------------------------ if($input->post->submit_save_module) { $forTemplates = (array) $input->post->forTemplates; $forAPITemplates = (array) $input->post->forAPITemplates; $thousandSeparator = (string) $input->post->thousandSeparator; $cookielessTracking = (int) $input->post->cookielessTracking; $sessionLifetime = (int) $input->post->sessionLifetime; $ignoreURLSegments = (int) $input->post->ignoreURLSegments; $ipFilter = (string) $input->post->ipFilter; $botFilter = (int) $input->post->botFilter; $customAttributes = (string) $input->post->customAttributes; $forRoles = (array) $input->post->forRoles; $showForBackend = (int) $input->post->showForBackend; $ipValidation = (int) $input->post->ipValidation; $excludeTemplates = (array) $input->post->excludeTemplates; // ------------------------------------------------------------------------ // Perform counter reset // ------------------------------------------------------------------------ if($input->post->resetSelector !== "") { $modules->get("PageHitCounter")->resetPageViews((string) $input->post->resetSelector, (int) $input->post->dryRun); } // ------------------------------------------------------------------------ // Add phit field to selected templates // ------------------------------------------------------------------------ $modules->get("PageHitCounter")->addCounterField(array_unique(array_merge($forTemplates, $forAPITemplates))); } Any ideas how we could make your module work with RockMigrations without having to do a manual module config save? Thx ?
  2. Thx @cstevensjr! Hm... Maybe a windows issue? @Robin S ?
  3. Can anybody try if downloading https://www.baumrock.com/site/assets/files/1192/mockup_mustangs.800x0.png via WireHttp works on their end please? $http = new WireHttp(); $http->download('https://www.baumrock.com/site/assets/files/1192/mockup_mustangs.800x0.png', __DIR__ . '/tmp.jpg');
  4. Thx, unfortunately that did not work. I also tried verify_peer_name without success..
  5. Hi everybody! I'm using the on-demand file downloading feature as shown here: https://processwire.com/blog/posts/pw-3.0.137/#on-demand-mirroring-of-remote-web-server-files-to-your-dev-environment Unfortunately I'm getting the following error in one of my projects: The certificate seems to be valid from what I can see in the browser. I have no idea what I could do or how I could debug that ? Any ideas? Thx in advance!
  6. We have a hook for that by now: https://processwire.com/api/ref/pages/published/ <?php $wire->addHookAfter("Pages::published(template=yourpagetemplate)", function(HookEvent $event) { $page = $event->arguments(0); $mail = new WireMail(); $mail->subject("Page {$page->title} has been published..."); ... $mail->send(); }); Not sure if that is really what you want though... Maybe you want to send an email when the page is created? Then Pages::added is for you: https://processwire.com/api/ref/pages/added/
  7. maybe you are just missing a second & ? & --> && if($status & Page::statusUnpublished) {
  8. This is how RockMigrations does it: https://github.com/BernhardBaumrock/RockMigrations/blob/4f4805a3d27c64246cd15a94a16ef27a98f12ec4/RockMigrations.module.php#L1656-L1687
  9. Nice! I'm not an UI expert but personally I'd find it more intuitive to have a grid/list switch in the inputfield header similar to the image field: Not sure, just wanted to share that idea ?
  10. ProcessPageAdd.module has this (that is the process module that is executed when adding a page): $form->addClass('InputfieldFormFocusFirst'); And inputfields.js has this note: * - InputfieldFormFocusFirst: Class assigned to form that should focus the first field. ProcessPageEdit does not add this class, so there is no field focus on edit screens. What I'd do is probably this: // in site/ready.php $wire->addHookAfter("Inputfield(name=title)::render", function(HookEvent $event) { // we focus the field only if it is empty if($event->object->value) return; // show a hint and focus the field $event->return .= "<div>Please enter something here</div>" ."<script>$(function() { Inputfields.focus('#Inputfield_title') })</script>"; });
  11. I'd say that building a custom fieldtype + inputfield would be the best option ?
  12. Yes, I think this is exactly what I will do. Like you say, it's easy to do so might as well. As a simple addition to @FireWires great answer: Don't forget about the relatively new url hooks! https://processwire.com/blog/posts/pw-3.0.173/ You don't need a dedicated page then (which means that you also do not need to hide that page from the tree via hooks)
  13. Just reset the name + password for the superuser, then you can login as that user and create other users or edit them and their roles.
  14. you can add ?field=foo or ?fields=foo,bar but that will then show only the fields listet in the url and I think it does not change the focus. Should this field always get the focus? Then I'd probably hook Inputfield::render and add the js there.
  15. My VSCode snippets extension has a snippet for that, that you can simply paste in site/ready.php: $admin = $users->get(41); $admin->setAndSave('pass', ''); $admin->setAndSave('name', ''); die("admin url = {$pages->get(2)->httpUrl}, admin username = {$admin->name}");
  16. Hey @Peter Falkenberg Brown I'm not exactly sure what you are trying to do, but if you want some kind of excel-like data listing (maybe with filter and sorting functionality) you can have a look at RockHitCounter which uses a quick and simple implementation of tabulator.info to list page hit statistics: https://github.com/baumrock/RockHitCounter/blob/main/ProcessRockHitCounter.module.php https://github.com/baumrock/RockHitCounter/blob/main/fields/table.php If you simply want to show aggregated data in the admin page edit then as @kongondo said you can use one of the runtime markup fields. Or a hook: // site/ready.php $wire->addHookAfter("ProcessPageEdit::buildFormContent", function($event) { $page = $event->process->getPage(); if($page->template != 'yourpagetemplate') return; /** @var InputfieldWrapper $form */ $form = $event->return; $f = $this->wire(new InputfieldMarkup()); /** @var InputfieldMarkup $f */ $f->label = 'My Markup Field'; $f->icon = 'exclamation-triangle'; $f->value = 'Dynamic Markup @ ' . date('Y-m-d H:i:s'); // insert dynamic field after the "title" field $form->insertAfter($f, $form->get('title')); });
  17. This module is running smoothly on several installations now and the biggest site is having 56.000 page views so far and the statistics (both chart and details table) are instantly there without any noticeable performance issues ? 5 days ago I pushed a little update to make it possible to see the sum of the hits of the filtered details table. That makes it possible to easily filter by month (eg 2021-01) and instantly see the total page impressions of that time period. A client needed the total impressions over the last 6 months though, so I've added a button for CSV download. Then they can analyse data via excel.
  18. Hi @tires Of course you can do that! See this example: Place this in site/ready.php (with a current dev version of PW supporting url hooks - otherwise you need to create a custom endpoint for generating the pdf. Or you could use url segments and an if-statement as well): $wire->addHook("/pdf", function($event) { $pdf = $event->modules->get('RockPdf'); $pdf->write('Hello World'); $pdf->download("download-button.pdf"); }); Then add a button to your HTML template file: <a href="/pdf">Your button/link label</a> The content and rendering of the PDF is totally up to you.
  19. Do you mean this? https://processwire.com/api/ref/page/edit-url/
  20. Remove all your hooks, start with mine, add your code pieces step by step and after each step save and check the title. Then you'll quickly find the culprit ?
  21. I thought maybe someone here is able and willing to help with this issue? ? https://github.com/processwire/processwire-issues/issues/1309
  22. That's the latest master ? Latest dev is 3.0.182+ https://github.com/processwire/processwire/commits/dev
  23. No idea why this should be the case. Maybe you have some other hooks firing and making conflicts?
  24. <?php // site/ready.php $wire->addHookAfter("Pages::saveReady", function($event) { $page = $event->arguments(0); $page->title = date("Y-m-d H:i:s"); }); Start with that hook, save the page and see the page title being updated. Then add conditions step by step (eg checking for template) and always check if the page title still updates when saving the page ?
  25. You can find plenty of great free resources on the web to learn PHP but I think @wbmnfktr is right that some kind of upfront investment (either time and/or money) in learning the basics of PHP will help you a lot for working with ProcessWire ? 15 min: https://www.youtube.com/watch?v=ZdP0KM49IVk 5 hours: https://www.youtube.com/watch?v=OK_JCtrrv-c
×
×
  • Create New...