Jump to content

dotnetic

Members
  • Posts

    923
  • Joined

  • Last visited

  • Days Won

    9

dotnetic last won the day on January 20

dotnetic had the most liked content!

Contact Methods

  • Website URL
    https://dotnetic.de
  • Skype
    jens.martsch

Profile Information

  • Gender
    Male
  • Location
    Münster, Germany

Recent Profile Visitors

10,662 profile views

dotnetic's Achievements

Hero Member

Hero Member (6/6)

1k

Reputation

  1. 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.
  2. 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.
  3. 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.
  4. It was an installation with redirect hooks in ready.php or something like that. It worked directly in a different project.
  5. 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, ] );
  6. I tested the module on Windows 11 with Laragon, Apache 2, PHP 8.0.12 and ProcessWire 3.0.193 and it works 👍
  7. Are you talking about the native Fieldtype or the module? Do you have both installed and selected which to use?
  8. @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)
  9. @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.
  10. I could not have it said better than @MoritzLost did and totally agree. But maybe you can move your post to the new thread?
  11. @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.
  12. 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:
  13. 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.
  14. @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.
×
×
  • Create New...