-
Posts
6,314 -
Joined
-
Last visited
-
Days Won
318
Everything posted by bernhard
-
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
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 -
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...
-
How to search with "find()" in all the languages?
bernhard replied to donatas's topic in Multi-Language Support
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'"); -
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 ?
-
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
-
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); } });
-
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?
-
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();
-
https://processwire.com/api/ref/wire-mail/attachment/
-
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
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: ? -
See the link "afraid of hooks" in my sig ?
-
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')); });
-
There are many ways ? What are you trying to do exactly and why? This helps finding the best solution ? Welcome to the forum btw!
-
@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 ?
-
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"); });
-
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
v0.0.53 It always annoys me not to have the correct page name replacements for german umlauts... -
two processwire installation, in other subdirectories
bernhard replied to sirhc's topic in General Support
If using subdomains is an option I think it would be easier to serve the blog from blog.example.com -
Admin - show content from a field on another page
bernhard replied to sambadave's topic in General Support
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 -
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 ?
-
@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
-
@adrian would it be possible to get a refresh&clear link here? I'm developing processmodules quite extensively those days and when adding a new nav item I always need to click "refresh" for triggering the module to catch the changes and then "clear session and cookies" to make the change visible in the menu. It would be great to get all that via one click. We know how annoying plenty of reloads get when we have to use them a lot... ? Thx for considering!
-
But it will not help others that may have the same problem in the future ?
-
Thx, unfortunately that does not help. That's now a regular line chart having "stupid" axis that are not aware of the date (having wrong sort order and wrong distance). Also I'd really need some help how to use all the examples in the docs and how I can customize them for my needs... The installation section (https://www.chartjs.org/docs/latest/getting-started/installation.html) does not help me either - I have no idea about all those module packer systems. I've tried to do some research but it did not help.. Maybe someone can give me pointers in the right direction ? thanks!
-
Looking at the recent discussion in this thread I wonder if the distinction between your module and mine is not about having a UI or not but is more about where and how you want to use it. I have never ever had the need for "migrating" content of an RTE field to another site for example. And I have never ever had the problem of changing ids on that process. Why? Because my module relates to everything BUT content. Content should be part of the site and not part of the migration. That means I can develop a system that I can setup multiple instances of (for example a local dev and a live production system, or as another example this could also be one setup for sports clubs that is used by multiple sports clubs running the same system and getting the same updates - but keeping thier content). Your module seems to be targeted to another world. Migrating content (and maybe also necessary config fields/templates) from one site to another? Am I right or did I get a wrong impression here?