Jump to content

Paul Greinke

Members
  • Posts

    4
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Paul Greinke's Achievements

Newbie

Newbie (2/6)

5

Reputation

  1. Hi there. I was wondering, if there was a best practice to handle file uploads outside of the admin frontend. For example if I had a form were a guest user can put some data including a file. I would like to upload the file on input and process it later on form submit. The problem is, that the user also could choose not to submit the form. That would lead to a bunch of unused uploads. In one project I use the PHP session. I simply create a folder named by the session id. Each time the user enters the page with the file upload I initially wipe all the data form the session folder. But this already does not work, if the user had the form opened in two separate browser tabs. Is there maybe a way to hook into the session invalidation process? Than way I could simply delete the session folder as soon as the session expires. I know I could use a cronjob or even lazycron, but I don´t find this a clean way for my case. Another idea of mine was to use some kind of caching folders. I saw that for example FormBuilder does it that way. But I did not find much information about how the caching works in ProcessWire. When is the cache cleared and how much control do I have? Maybe there is a even better and more convenient way to do it. I'll take any idea.
  2. I stumbled across this post searching for the reason why my module won't create the process page under setup. I tried some suggestions from this threat, but eventually found another solution. I just wanted to share this in case someone needed it. I used the getModuleInfo() function to add a page. I did not prefix my modules name with "Process" but only extended it with the Progress class. The only thing I had to do was calling the parents install() method in my modules install() method. That`s it. Now the setup page is created automatically on install. <?php namespace ProcessWire; class MyModule extends Process implements ConfigurableModule { public static function getModuleInfo() { return [ 'title' => 'My Module', 'summary' => 'A module', 'version' => 1, 'page' => array( 'name' => 'mymodule', 'parent' => 'setup', 'title' => 'My Module', ) ]; } public function install() { parent::___install(); } public function uninstall() { parent::___uninstall(); } }
  3. My bad, I figured it out. In order to work the class only needs to extend WireData. So the following example works. <?php class MyClass extends WireData { public function ___someFunction() { // Do something } } // ready.php $this->addHookBefore('MyClass::someFunction', function($event) { // some customization });
  4. Hi there. I wrote a custom module for one of my projects. In fact I maybe want to use my module in other projects too. In order to be variable and customizable I need to implement some custom hooks into my module. So I can afterwards hook into the my functions in order to modify them to match the needs of the new project. I tried simply defining functions with the '__' prefix. But that did not work. I'm imagining something like the following: <?php class MyClass { public function ___someFunction() { // Do something } } // ready.php $this->addHookBefore('MyClass::someFunction', function($event) { // some customization }); Is there a way to accomplish that?
×
×
  • Create New...