Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Juergen

  1. BTW: You will get also a notice that your system does not fulfill the requirements if you have not installed LazyCron (not only if the PHP version is lower). You can ignore this, because LazyCron will be installed automatically during the module installation, if it is not installed. Unfortunately, Processwire gives you a warning that your system does not fulfill the requirements for the module, but not exactly what the problem is. 😔
  2. No, it should work with 8.0, but not below. I have not checked it directly on my local server, but PHP-Storm does not complain after changing the version. I have changed the version on GitHub too, but you do not need to download it again. Please let me know, if something unexpected occurs, but I guess it will not.... BTW: In the module configuration settings set the CronJob interval to 1 minute for testing purposes, so you can check the functionality immediately. Later on, setting the value to 1 hour again, will be enough. Best regards
  3. Glad to hear that! 😀 Let me know, if you discover any issues. I will add this as soon as possible to the ProcessWire module directory, but as written, it needs to be tested first by several people.
  4. This is a reissue of a module of mine called "PublishingOptions", that I wrote a while ago. The big difference is that this module is written in PHP 8 and has some nice additional features. The old module could only publish and unpublish pages depending on date and time settings, but the new version goes much further. So you can decide what should happen after the publication end date has been reached. You have the following options: Unpublish the page - this is what the old version did Move the page to trash - new Delete the page permanently- new Move the page to a new position in the page tree - new The last option will be interesting if you want to move the page fe to an archive after a certain date. You can select the new parent page and after the publication end date has been reached, the page will be moved under the new parent page. You will find a more detailed instruction and download possibility at https://github.com/juergenweb/JkPublishPages This module is Alpha stage and should be tested carefully before using it on live sites. I have planned to add this module to the PW module download section, so everyone is invited to test it out and to report issues directly at GitHub. Thanx
  5. Thank you @wbmnfktr and @BitPoet for your suggestions. I have forgotten to write, that I have a working solution by using a foreach loop, but my goal was to get rid of the loop and to use a selector instead. I only wanted to simplify the code to increase the performance. This is the reason and therefore there is no possiblity to use a selector in this case, so I close this thread and use the loop 🙁
  6. Hello @ all Is there a possibility to filter a TemplatesArray by the selector childTemplates, which has an array as value? I have searched the net, but I have not found a solution. The problem seems to be that the value is an array and not a string. This does not work: $templates->find('childTemplates=[29,30]); This does not work too: $templates->find('childTemplates=29|30'); Has anyone an idea?
  7. Hello @bernhard First of all, thank you for your feedback. 🙂 To be honest, I did not even think about using a svg for a placeholder - but this is also a really cool idea too. BTW thanks for the link - I will take a closer look at this. Referring to your questions: My intention was to use it for real website users (as placeholder images for products, user images and so on). I did not want to use to much different font families on a site. For this reason I thought that it was cool to be able to use the same font for the text in the placeholder image as used for the text of the site. This is possible with this module. Another aspect was that a "real image" could be used without problems with CSS frameworks componentes, whenever an image is needed. I am thinking of the comment component of the UiKit framework. In the markup you will need an image tag for the user image. Of course you can replace the image tag by a div container with text inside or another tag (picture, image tag for svg,..), but you have to adapt the CSS of the framework to get the desired result. Using an usual image tag, as provided with this module, requires no changes. Have a nice weekend!😀 Jürgen
  8. Hello @ all I want to introduce a module to you which can create placeholder images on the fly. This module was developed a few years ago, but I have completely rewritten the code to PHP 8.1 and added some nice additional features. You can find the complete description and download possibility at https://github.com/juergenweb/JkImagePlaceholder, but I want to give you a brief description about the module. Short description: This module uses TrueType fonts for the placeholder text. 2 TTFs are shipped with this module by default (FjallaOne-Regular.ttf and Lobster-Regular.ttf). Allows upload and deletion of other fonts Allows scanning the complete site to find and use other TrueTypeFonts (fe used by templates or other modules) Preview of all fonts in the select font input field - you can see how the font looks like Global setting of various colors: background color, text color,.. Supports adding of text shadow to the placeholder text Set global placeholder text (multi-language) Set global image tag CSS class for the placeholder image tag If you have installed FieldtypeColor or FieldtypeColorPicker you can select if you want to use one of these fields for color inputs instead of a text input. Preview example: The easiest way to create the placeholder image inside your template file: echo $modules->get('JkImagePlaceholder')->render(true); This will render the placeholder image according to your global settings in the module configuration, but you can change every parameter to your needs: echo $modules->get('JkImagePlaceholder') ->setText('Test!') ->setAltText('My custom alt text for the image') ->setFontSize(30) ->setWidth(400) ->setHeight(200) ->setBackgroundColor('#ddd') ->setFontFamily('lobster-regular.ttf') ->setTextColor('#ffffff') ->setShadowColor('#000') ->setXOffset(-5) ->setYOffset(1) ->render(true); Everything is explained in the Readme file on GitHub. If you discover issues, please report it directly on GitHub🙂 - Thanx for your help!
  9. Hello @abmcr Why do you not extend the button drop down with your pdf feature instead of adding a new button. BTW: Adding a second save button was the way to go a at the time where PW did not offer the possibility for a drop down button. To get an additional dropdown level for PDF, please put the following piece of code inside your site/templates/init.php or site/templates/ready.php. If the files do not exist by default, you have to create them manually. $wire->addHookAfter('ProcessPageEdit::getSubmitActions', function($event) { $actions = $event->return; $actions[] = [ 'value' => 'value of action, i.e. view, edit, add, etc', 'icon' => 'file-pdf-o', 'label' => 'Pdf', 'class' => 'btn_pdf_plan', ]; $event->return = $actions; }); Only to mention: do not forget to change the value to your needs (fe save in your case). Best regards
  10. Hello @ all I am using a lot of hooking of methods and I want to optimize the performance of a module a little. In my case I use the following Hooks inside my modules init() method: public function init() { $this->addHookBefore('Page::render', $this, 'function1'); $this->addHookBefore('Page::render', $this, 'function2'); $this->addHookBefore('Page::render', $this, 'function3'); $this->addHookBefore('Page::render', $this, 'function4'); } As you can see, I am always hooking the same method (Page::render) to run different functions. The functions itself are declared outside of the init() method. My question: Would it have an impact on the performance if I would fe summarize function1 to function4 into one function (see below) or does it not matter? public function init() { $this->addHookBefore('Page::render', $this, 'summarizeFunction'); } protected function summarizeFunction() { $this->function1(); $this->function2(); $this->function3(); $this->function4(); } As you can see, I have only 1 hook left, that hooks into Page::render - not 4 as before. I have not try it, if there would be a significant performance boost or not. I only want to ask some other devs if they have experiences if this could be optimize the performance a little bit or not. Best regards
  11. Thanks @Jan Romero What a silly mistake!!! 😨😭You are right: Sure, that was the mistake. I know that it must be $event and not $field, but I have overlooked this silly mistake over and over and I was wondering why it did not work. I have tried it with $event->object and $event->arguments(0).... BTW: Now both Hooks work with $event->arguments(0)!! Thanks for your help!!! Thanks for helping me
  12. Hello @all I have searched the forum and studied the PHP class files, but I cannot find a way to achieve the following one: I want to run a Hook after the pass field (a system field) is saved. It should also work with other inputfields, but in my case I need to run it especially on the pass field. To clearify: I want to run the Hook if the "Edit field: pass" page is saved. I have tried the following inside the init() function of my module: $this->addHookAfter('Fields::save', $this, 'updateBlacklist'); The appropriate method: protected function updateBlacklist(HookEvent $event): void { $field = $field->object; if ($field->name == 'pass') { $this->wire('session')->message('works'); } } But it does not work. As mentioned by @LostKobrakai at this topic, " Field::save is called when a fieldsettings should be saved", but it seems that nothing happens. Could anyone point me into the right direction?
  13. Thanks @flydev I thought that this is called type declaration. I have used this for a while, but I did not knew, that this was called union type. Now I have learnt something new today.🙂 The problem is solved for flashmaster82, we have discussed the issue via PM. The module itself should check if version 8.1 is installed. 'requires' => ['PHP>=8.1.0', 'ProcessWire>=3.0.181'] So it should give you a warning message before the installation process starts.
  14. UPDATE!! A new version with CAPTCHA support can be downloaded at https://github.com/juergenweb/FrontendForms It is early stage, so everyone is invited to test it - not recommended on live sites at the moment. Please report errors and ideas directly in Github. Thanks Jürgen
  15. Hello Luigi I found the problem: The blank profile uses markup regions and therefore you have to copy the code of the form between a div with the id "content". Take a look at the code afterwards: <?php namespace ProcessWire; /** * Demonstration of a complex form * You can copy this code to a template to show the form * If you use these classes inside another namespace (fe ProcessWire) like in this case, you have to take care about the namespace in front of the class instances. * Fe you have to use $form = new \FrontendForms\Form('myForm'); or $form = new FrontendForms\Form('myForm'); and not only $form = new Form('myForm'); */ echo '<div id="content">'; echo '<h1>Complex form</h1>'; $form = new \FrontendForms\Form('registration'); $form->setMinTime(8); $form->setMaxTime(3600); $form->setMaxAttempts(5); $form->setErrorMsg('Ouups! There are some errors.'); $form->setSuccessMsg('Congratulation! There are no errors.'); $userdata = new \FrontendForms\FieldsetOpen(); $userdata->setLegend('User data')->append('<p>Please fill out all required fields.</p>'); $form->add($userdata); $singleRadio = new \FrontendForms\InputRadio('single'); $singleRadio->setLabel('Single radio button'); $singleRadio->setAttribute('value', 'single'); $singleRadio->setRule('required'); $singleRadio->setNotes('This field makes no sense'); $form->add($singleRadio); $gender = new \FrontendForms\InputRadioMultiple('gender'); $gender->setLabel('Gender')->setAttribute('class', 'myextralabelclass'); $gender->setDefaultValue('Male'); $gender->addOption('Male', 'Male')->setAttribute('class', 'male'); $gender->addOption('Female', 'Female')->setAttribute('class', 'female'); $gender->addOption('Diverse', 'Diverse')->setAttribute('class', 'diverse'); $gender->getFieldWrapper()->setAttribute('class', 'uk-width-1-1')->removeAttributeValue('class', 'uk-margin'); $form->add($gender); $firstname = new \FrontendForms\InputText('firstname'); $firstname->setLabel('Firstname'); $firstname->setRule('required'); $firstname->getFieldWrapper()->prepend('<div class="uk-child-width-1-2" data-uk-grid>')->removeAttributeValue('class', 'uk-margin'); $form->add($firstname); $lastname = new \FrontendForms\InputText('lastname'); $lastname->setLabel('Lastname'); $lastname->setRule('required'); $lastname->getFieldWrapper()->append('</div>')->removeAttributeValue('class', 'uk-margin'); $form->add($lastname); $street = new \FrontendForms\InputText('street'); $street->setLabel('Street'); $street->setRule('required'); $street->getFieldWrapper()->setAttribute('class', 'uk-width-3-4')->prepend('<div data-uk-grid>')->removeAttributeValue('class', 'uk-margin'); $form->add($street); $number = new \FrontendForms\InputText('number'); $number->setLabel('Number'); $number->setRule('required'); $number->setRule('integer'); $number->getFieldWrapper()->setAttribute('class', 'uk-width-expand')->append('</div>')->removeAttributeValue('class', 'uk-margin'); $form->add($number); $email = new \FrontendForms\InputEmail('email'); $email->setLabel('Email address'); $email->setSanitizer('email'); $email->setRule('required'); $email->setRule('email'); $email->setRule('emailDNS'); $email->getFieldWrapper()->prepend('<div class="uk-child-width-1-3" data-uk-grid>')->removeAttributeValue('class', 'uk-margin'); $form->add($email); $phone = new \FrontendForms\InputTel('phone'); $phone->setLabel('Phone'); $phone->setRule('integer'); $phone->getFieldWrapper()->removeAttributeValue('class', 'uk-margin'); $form->add($phone); $fax = new \FrontendForms\InputText('fax'); $fax->setLabel('Fax'); $fax->setRule('required')->setCustomFieldName('Fax number'); $fax->getFieldWrapper()->append('</div>')->removeAttributeValue('class', 'uk-margin'); $form->add($fax); $birthday = new \FrontendForms\InputDate('birthday'); $birthday->setLabel('My birthday'); $birthday->setRule('required')->setCustomFieldName('The day of my birth'); $birthday->setRule('date'); $form->add($birthday); $children = new \FrontendForms\InputNumber('children'); $children->setLabel('Number of children'); $children->setAttribute('min', '0'); $children->setAttribute('max', '15'); $children->setRule('required')->setCustomMessage('Please enter how much children do you have'); $form->add($children); $userdataClose = new \FrontendForms\FieldsetClose(); $form->add($userdataClose); $interestsOpen = new \FrontendForms\FieldsetOpen(); $interestsOpen->setLegend('My interest'); $form->add($interestsOpen); $interests = new \FrontendForms\InputCheckboxMultiple('interest'); $interests->setLabel('I am interested in'); $interests->setDefaultValue('Web-design'); $interests->addOption('Music', 'Music')->setChecked(); $interests->addOption('Web-design', 'Web-design'); $interests->addOption('Sports', 'Sports')->setChecked(); $interests->addOption('Photography', 'Photography'); $firstname->setRule('required'); $interests->alignVertical(); $form->add($interests); $php = new \FrontendForms\Select('php'); $php->setLabel('My preferred PHP version is'); $php->setDefaultValue('PHP 8'); $php->addOption('PHP 6', 'PHP 6'); $php->addOption('PHP 7', 'PHP 7'); $php->addOption('PHP 8', 'PHP 8'); $form->add($php); $css = new \FrontendForms\SelectMultiple('css'); $css->setLabel('I have knowledge in'); $css->setDefaultValue('Less', 'CSS 1'); $css->addOption('CSS 1', 'CSS 1'); $css->addOption('CSS 2', 'CSS 2'); $css->addOption('CSS 3', 'CSS 3'); $css->addOption('Less', 'Less'); $css->addOption('Sass', 'Sass'); $form->add($css); $interestsClose = new \FrontendForms\FieldsetClose(); $form->add($interestsClose); $accept = new \FrontendForms\InputCheckbox('accept'); $accept->setLabel('I accept the data privacy'); $accept->setRule('accepted')->setCustomMessage('You have to accept the data privacy'); $form->add($accept); $newsletter = new \FrontendForms\InputCheckbox('newsletter'); $newsletter->setLabel('I want to register to the newsletter'); $newsletter->setChecked(); $form->add($newsletter); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', 'Send'); $form->add($button); if ($form->isValid()) { print_r($form->getValues()); // or do what you want } // render the form echo $form->render(); echo '</div>'; As you can see the form code is between the opening and closing tags of the content container. BTW I have sent you a PM with the new version. Best regards Jürgen
  16. I am sorry, that I cannot help you, but I am unable to reproduce the error and without any error messages I have no starting point. As written above, I am working on the improved version, which will be (hopefully) ready to use within the next days. I can inform you if it will be ready to download if you want. Best regards Jürgen
  17. Sorry, but I cannot post a possible cause for this behavior here. I have removed all fields and added it step by step to the configuration form again until the form was completed. This time no problem occurs. I cannot reproduce the failure, but I guess there was a JS problem, because the button could not be clicked to submit the form. So the thread will be closed.
  18. Thanks @Robin S for your feedback. I have disabled all inputfields on the configuration form except this InputfieldInteger and now it works too. It seems that there will be a combination of fieldsets, other inputfields, whatever that causes this strange behavior. I keep this thread open, until I have found the reason and post it her. Best regards Jürgen
  19. Hello @ all, today I have discovered a possible bug on the InputfieldInteger form field with the step attribute. After adding the step attribute the submit button to save the module configuration page does not work anymore. This behavior only occurs if the type of the InputfieldInteger is set to number. If set to text everything works fine. Take a look at https://processwire.com/api/ref/inputfield-integer/ Lets take a look at the code: // this does not work -> input type set to number $integerfield = $this->modules->get('InputfieldInteger'); $integerfield->inputType = 'number'; $integerfield->step = 10; // this works $integerfield = $this->modules->get('InputfieldInteger'); $integerfield->inputType = 'text'; $integerfield->step = 10; I did not get any error message, but as mentioned above, the submission does not take place. If someone could test this on a configurable module and confirm or deny this behavior, before I open a new issue. Best regards Jürgen
  20. Please also check in the module configuration settings that in the blacklist of forbidden IDs is not your IP address listed. I can remember that in the old version a Javascript mistake causes that the local IP address was stored inside this field and has to be deleted manually. This was a bug. Currently I am working on an improved version without JS and it works as expected - but this version has to be tested and is not ready to use for the moment. So please check this setting too.
  21. Usually not, but in your case it seems that a loop produces the repeats, but I dont know where it is located. I have tried it o a local installation (XAMPP) and it works as expected. So the cause should be somewhere on your side. Can you tell me which of the PW profiles do you use (Uikit, blank profile, blog,...) Do you have the installation locally on XAMPP etc too or is it public reachable, so I can take a look. Best regards
  22. Hi Luigi! Very strange! Could you please post the whole php code of the template where you have integrated the form. Cu Jürgen
  23. Thanks @teppo I have thought that this will be the problem. I think I will create an extra folder with the required permissions for this reason.
  24. Hello @ all I want to create a captcha image for a form, which can be reloaded on demand, if the user cannot read the captcha. The form will be created by a module, that is why this question is inside this category. For this reason I want to create the captcha image on the fly by using a PHP file as image source instead of an image file. // in a template file $path = $config->urls->assets.'files/captchaimage.php'; echo '<img src="'.$path.'" />'; As you can see: the image source is not an image file (fe. captcha.png), it is a PHP file which creates the image on the fly. I have added this file to site/assets/files because this folder can be reached from outside. The captchaimage.php consists of the following code (only for testing purposes): <?php header("Content-Type: image/png");//change the php file to an image $im = @imagecreate(110, 20) or die("Cannot Initialize new GD image stream");//creates an image with the resolution x:110 y:20 $background_color = imagecolorallocate($im, 0, 0, 0);//create a color with RGB $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);//draws text to the image with the font:1 xpos:5 ypos:5 imagepng($im);//sends the image data to the user imagedestroy($im);//destroys the image from the server ?> This is not the real code for producing the captcha - it is only a simple code to create an image. My problem is, that I cannot output the image on the template. I always get the message, that the image could not be loaded. Can someone point me in the right direction, why this does not work? Thanks in advance
  25. I found a workaround: Put the user language inside a session variable and call this session variable inside the hook. public function init() { //set language id inside a session variable for later usage in url hook $this->wire('session')->set('userlang', $this->wire('user')->language->id); // Show details about the blocked IP address inside a panel $this->wire->addHook('/detail-view/{ip}', function ($event) { $userLang = $this->wire('session')->get('userlang'); // grab current user lang from session $this->wire('user')->language = $userLang; // here comes the code }); } Not really elegant, but it works. Now translatable strings work as expected.
  • Create New...