-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
Page Hit Counter – Simple Page View Tracking
bernhard replied to David Karich's topic in Modules/Plugins
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 ?- 111 replies
-
- hitcounter
- tracking
- (and 4 more)
-
SSL error when loading files on demand (certificate verify failed)
bernhard replied to bernhard's topic in General Support
Thx @cstevensjr! Hm... Maybe a windows issue? @Robin S ? -
SSL error when loading files on demand (certificate verify failed)
bernhard replied to bernhard's topic in General Support
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'); -
SSL error when loading files on demand (certificate verify failed)
bernhard replied to bernhard's topic in General Support
Thx, unfortunately that did not work. I also tried verify_peer_name without success.. -
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!
-
Need to send email notification after a page has been published
bernhard replied to Lars282's topic in Modules/Plugins
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/ -
Need to send email notification after a page has been published
bernhard replied to Lars282's topic in Modules/Plugins
maybe you are just missing a second & ? & --> && if($status & Page::statusUnpublished) { -
This is how RockMigrations does it: https://github.com/BernhardBaumrock/RockMigrations/blob/4f4805a3d27c64246cd15a94a16ef27a98f12ec4/RockMigrations.module.php#L1656-L1687
-
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 ?
-
How to set field focus in ready.php
bernhard replied to Peter Falkenberg Brown's topic in API & Templates
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>"; }); -
I'd say that building a custom fieldtype + inputfield would be the best option ?
-
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)
-
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.
-
How to set field focus in ready.php
bernhard replied to Peter Falkenberg Brown's topic in API & Templates
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. -
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}");
-
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')); });
-
[alpha] RockHitCounter - Historical Data + Charts for PageHitCounter
bernhard replied to bernhard's topic in Modules/Plugins
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. -
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.
-
How to relate page and corresponding "editing" page in admin?
bernhard replied to Clarity's topic in Getting Started
Do you mean this? https://processwire.com/api/ref/page/edit-url/ -
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 ?
-
Tap on image thumbnail doesn't work on Android+Chrome
bernhard posted a topic in Themes and Profiles
I thought maybe someone here is able and willing to help with this issue? ? https://github.com/processwire/processwire-issues/issues/1309 -
That's the latest master ? Latest dev is 3.0.182+ https://github.com/processwire/processwire/commits/dev
-
No idea why this should be the case. Maybe you have some other hooks firing and making conflicts?
-
<?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 ?
-
What php code should I use to link the same html code?
bernhard replied to franciccio-ITALIANO's topic in Getting Started
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