Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by dotnetic

  1. The module wasn't working because the home template had a setting of "allow url segments", so the URL hook was not working. Without the setting it works fine.
  2. The easiest and best way to setup this stack in my opinion is ddev. DDEV is an open source tool that makes it dead simple to get local PHP development environments up and running within minutes. It's powerful and flexible as a result of its per-project environment configurations, which can be extended, version controlled, and shared. In short, DDEV aims to allow development teams to use Docker in their workflow without the complexities of bespoke configuration. Me and @bernhard use it, and are very satisfied. I am using it on Windows 11 inside of WSL2. But it also runs on Macs and Linux machines.
  3. Just released the new version of the german language pack for stable version 3.0.200
  4. I think I will have a look at the changes on friday, if I find the time.
  5. Well, @fruid stated, that he already used halt and it did not work. I experienced the same (but I am also using Smarty Template Engine), thats why I use die() instead.
  6. You can not enter JavaScript into the CKEditor, as it is stripped out by the HTML purifier. It could also be a security problem if the editor allows this. I suggest you add your widget code on the site/templates/pagename.php where you need it.
  7. I am also about to post a comment with a reference to my article Warum ProcessWire das beste CMS für Ihre Website ist - dotnetic. I also have some issues with ProcessWire's structure and other different stuff like migrations (see other threads), but it depends on the type of project, and how the developer sets everything up (if is not me). Overall PW served me very well through the years, and I have a big project with many monthly visitors running flawless on it.
  8. It was an installation with redirect hooks in ready.php or something like that. It worked directly in a different project.
  9. Hey guys, I found a solution to the problem when using url or httpUrl for images in the code for the PDF. If you use "$img->filename", then the image would not render if output to the browser, but only in the pdf file. You have to strip the rootUrl and replace "site" with "../../site", then you can have both, a working HTML page with images displayed and also afterwards a PDF also with images. I created a helper function for this: public function convertUrlToRelativeInPdf($html): string { $html = str_replace($this->rootUrl, '', $html); return preg_replace('/\/site/', '../../site', $html); } here is my helper function to generate all of my PDFs: /** * @param $html * @param $pdfName * @param $mode * @param $header * @param $footer * @param $body * @param $stylesheet * @param $page * @param $debug * @param $settings * @return string * @throws WireException * @throws WirePermissionException */ public function generatePdf($html = false, $pdfName = 'test', $mode = 'save', $header = false, $footer = false, $body = false, $stylesheet = false, $page = false, $debug = false, $settings = false): string { $pdf = $this->modules->get('RockPdf'); // $pdf->mpdf->curlAllowUnsafeSslRequests = true; // $pdf->mpdf->showImageErrors = true; // $pdf->mpdf->setBasePath ('https://shop.fugamo.de'); $html = $this->convertUrlToRelativeInPdf($html); $pdf->settings([ 'margin_left' => 20, 'margin_right' => 20, 'margin_top' => 55, 'margin_bottom' => 50, 'format' => 'A4', 'fontdata' => (new \Mpdf\Config\FontVariables())->getDefaults()[ 'fontdata' ] + [ 'sans-serif' => [ 'R' => 'Lato-Regular.ttf', 'I' => 'Lato-Italic.ttf', ] ], ]); if (is_array($settings)) { $pdf->settings($settings); } $stylesheet = file_get_contents($stylesheet) ?: file_get_contents($this->config->paths->templates . '/pages2pdf/styles.css'); // external css $stylesheet = "<style>$stylesheet</style>"; $pdf->write($stylesheet); if ($header && is_file($header)) $pdf->SetHTMLHeader($this->convertUrlToRelativeInPdf(wireRenderFile($header))); if ($body && is_file($body)) { if ($page) { $pdf->write($this->convertUrlToRelativeInPdf(wireRenderFile($body, ["page" => $page]))); } else { $pdf->write($this->convertUrlToRelativeInPdf(wireRenderFile($body))); } } else { $pdf->write($html); } if ($footer && is_file($footer)) $pdf->SetHTMLFooter($this->convertUrlToRelativeInPdf(wireRenderFile($footer))); if ($debug) { die($pdf->html()); } $returnValue = ""; switch ($mode) { case 'download': $pdf->download($pdfName . ".pdf"); $returnValue = "Das PDF wurde runtergeladen."; break; case 'show': $pdf->show($pdfName); break; case 'save': $pdfFile = $this->pdfPath . "$pdfName.pdf"; // die($pdfFile); $pdf->save($pdfFile); // $this->message("PDF wurde gespeichert: $pdfFile"); $returnValue = $pdfName. ".pdf"; break; case 'saveAndShow': $pdfFile = $this->pdfPath . "$pdfName.pdf"; $pdf->save($pdfFile); $pdf->show($pdfName); } bd($returnValue); return $returnValue; } and I call it like this $MyHelperModule = $this->modules->get('nameOfMyHelperModule'); // attention, I am using named parameters here, only available in PHP >= 8.0 $MyHelperModule->generatePdf( html: $html, pdfName: "Sammelauswertung-$id", // name mode: 'show', stylesheet: $this->config->paths->templates . '/pages2pdf/styles.css', // stylesheet settings: [ 'margin_left' => 10, 'margin_right' => 10, 'margin_top' => 20, 'margin_bottom' => 20, ] );
  10. I tested the module on Windows 11 with Laragon, Apache 2, PHP 8.0.12 and ProcessWire 3.0.193 and it works 👍
  11. Are you talking about the native Fieldtype or the module? Do you have both installed and selected which to use?
  12. @MoritzLost I didn't use worktrees yet, but one advantage that I have seen in videos is, that you have your own dependencies for each worktree. This can be a huge advantage if you use different node modules (or composer dependencies) between branches (maybe because you need an additional library for a feature branch)
  13. @Kiwi Chris @AndZyk @bernhard @wbmnfktr I tried to shift the conversation to this thread so we have a cumulated discussion and not all opinions and solutions cluttered around in several threads. Maybe a moderator could move your discussions here to the new thread if thats ok with you.
  14. I could not have it said better than @MoritzLost did and totally agree. But maybe you can move your post to the new thread?
  15. @Malinda Do you have the admin username and access to the files on the webserver? If so, you can following code to one of your templates, and set a new password for the admin user. Then you can log in with admin and the password you have chosen.
  16. The problem: Synchronizing fields and/or templates made on the dev server with the live server is cumbersome. At the same time, there is no version control of fields and templates, which some folks (including myself) see as a disadvantage of ProcessWire. A way to have version control to track changes and replicate automatically would be desirable. There is the template and fields export feature in ProcessWire which has said for ages that this is only a beta version, although I have used it many times without any problems. However, even with this method, it is very cumbersome to reconcile changes between dev and live. You have to remember which fields / templates you created and select them, then copy and paste them on the dev server. This is a manual, cumbersome and time consuming process. Existing solutions: For this reason, several solutions have been developed such as: Migrations by @LostKobrakai https://processwire.com/talk/topic/14603-rocksvn-brings-version-control-to-your-fields-templates/ ProcessWires Template's and field's export function https://processwire.com/modules/rock-migrations/ https://processwire.com/talk/topic/25307-oh-no-not-another-migration-module/ https://processwire.com/modules/auto-export-templates-and-fields/ Other systems like Laravel, Craft, Kirby and Statamic use configuration files (migrations, YAML) to manage fields / templates, which allow to create a state of fields / templates. Since the configuration is done in a file, you can of course manage it with git (or other vcs). By configuring in a file, it is also possible to automatically execute these migrations during a git push through different deploy pipelines like github actions, buddy, bitbucket pipelines and thus you have the desired state on the desired server. Where to go from here? In another post @bernhard showcased a prototype, that uses a YAML-file to create and manage fields / templates in ProcessWire. At the same time he showcased a YAML recorder which writes all changes that are made to templates and fields into a YAML file, which looks very promising: I think a combination of a recorder and a YAML config file would be a optimal solution, at least for me. What format to use for such a configuration file was and has also to be discussed:
  17. YAML is easier to read and write as PHP and less error prone (Yeah I know, we are devs, but there might be unexperienced devs / users that try to accomplish something fast). Indeed I agree, that PHP would offer more possibilities, but I think most times YAML or another configuration markup are enough. Every developer ist different here. Some might prefer writing directly to the file to change things or add new fields/templates, others prefer to do it via the admin. Update: I would like to shift this conversation to a newly created thread, because we are getting off-topic of sharing out setup/tools.
  18. @bernhard The YAML recorder and migration of the project.yaml look awesome. Any plans to release these additions to RockMigrations? I think this is a good way to make fields and templates version controlled. Having a feature like the YAML config and recorder added to the core would be a very good thing IMHO. The not programmable definition of fields and templates and migrating contents and structure to a live server is cumbersome (without RockMigrations) and led me to try out alternatives to ProcessWire in the past. I used Statamic and Kirby which both have configuration files for fields/templates, which can be version controlled and I really like the way it's done.
  19. @ryan Thanks for the added supported fields in the findRaw method. I am still having performance issues with my queries, but I try to find the bottleneck or might even provide you with a dump, so you can recreate the issue. However great update, that will come in handy.
  20. @Richard Jedlička I really like this approach. Where and how do you define your environment variables? Do you have a separate file for this and use the putenv command?
  21. Could you please describe more specific what you are trying to achieve? What you mean by "whitelist"?
  22. Here is another advantage of using composer: I am using an automated deployment process for my clients websites via github actions. Right now I have to put all modules in the modules directory under git control and commit every module update to git. This makes every module update another commit in the git log and the git repository very large. With composer.json I would just update one file and my github action (or buddy, or Vercel or whatever deployment tool you use) would install these dependencies.
  23. I think all modules should be installable via composer as it makes everything more maintainable. There is an composer installer for ProcessWire modules, so you just have to add a composer.json file to your module and the module will be installed in the right directory. Here is a good explanation One advantage of installing modules via compoeser is, that you can version control your composer.json file or have different modules based on your environment:
  24. I have added a request "findRaw should have support for joining parents and references" (and also for getting option field titles) here https://github.com/processwire/processwire-requests/issues/427 @adrian @thetuningspoon
  • Create New...