Jump to content

mjut

Members
  • Posts

    29
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mjut

  1. @Juergen wow! So good! Thanks for putting this up. This helps a lot. Not just for this form, I can actually learn from how you've rewritten certain snippets of this code. Thanks again!
  2. hmmyes. But that would make things even more complicated? (I am not really familar with ajax.) By the way: its super helpful that you provided the exmple files. very good organised an written. big ups!
  3. Thank you so much for the detailed answer! I see, there is a lot to learn for me ? I did use and edited your example from github contactform-2.php: <?php declare(strict_types=1); namespace ProcessWire; /* * File description * * Created by Jürgen K. * https://github.com/juergenweb * File name: contactform-2.php * Created: 15.02.2023 */ $form = new \FrontendForms\Form('contact'); $form->setMaxAttempts(0); // disable max attempts //$contacttype = new \FrontendForms\InputCheckboxMultiple('auswahl'); $contacttype = new \FrontendForms\InputRadioMultiple('auswahl'); //$contacttype->setNotes('*'); $contacttype->addOption('Einzelperson (Jahresbeitrag 50,00 EUR)<span class="asterisk">*</span>', 'Einzelperson (Jahresbeitrag 50,00 EUR)'); $contacttype->addOption('Doppelmitgliedschaft (Jahresbeitrag 75,00 EUR)<span class="asterisk">*</span>', 'Doppelmitgliedschaft (Jahresbeitrag 75,00 EUR)'); $contacttype->alignVertical(); $contacttype->setRule('required'); $form->add($contacttype); // add the gender field $gender = new \FrontendForms\Gender('gender'); //$gender->setLabel('Auswählen'); // so Label setzen! $form->add($gender); // add the name field $name = new \FrontendForms\Name('firstname'); $form->add($name); // add the surname field $surname = new \FrontendForms\Surname('lastname'); $form->add($surname); // add the name2 field $name2 = new \FrontendForms\InputText('firstname2'); $name2->setLabel('Vorname (zweite Person)'); $form->add($name2); // add the surname2 field $surname2 = new \FrontendForms\InputText('lastname2'); $surname2->setLabel('Nachname (zweite Person)'); $form->add($surname2); // Adresse $adresse = new \FrontendForms\InputText('adresse'); $adresse->setLabel('Straße und Hausnummer'); $adresse->setRule('required'); $form->add($adresse); // plz $plz = new \FrontendForms\InputText('plz'); $plz->setLabel('Postleitzahl'); $plz->setRule('required'); $form->add($plz); // Ort $ort = new \FrontendForms\InputText('ort'); $ort->setLabel('Ort'); $ort->setRule('required'); $form->add($ort); // add the email field $email = new \FrontendForms\Email('email'); if ($user->isLoggedIn()) { $email->setDefaultValue($user->email); } $form->add($email); // add the phone field $phone = new \FrontendForms\Phone('phone'); $phone->setLabel('Telefon / Mobil'); $phone->setRule('required'); $form->add($phone); // add the Geburtstags field $geb = new \FrontendForms\Phone('geb'); $geb->setLabel('Geburtsdatum'); $form->add($geb); $einzug = new \FrontendForms\InputCheckbox('einzug'); $einzug->setLabel('Hiermit ermächtige ich den Museumsverein Celle e.V. widerruflich, die von mir zu entrichtende Beitragszahlung jährlich bei Fälligkeit zu Lasten meines Kontos mittels Lastschrift einzuziehen. Wenn mein Konto die erforderliche Deckung nicht aufweist, besteht seitens des kontoführenden Geldinstituts keine Verpflichtung zur Einlösung.'); $einzug->setRule('required')->setCustomMessage('Bitte bestätigen Sie die Einzugsermächtigung.');; $form->add($einzug); // Kontoinhaber $kontoinhaber = new \FrontendForms\InputText('kontoinhaber'); $kontoinhaber->setLabel('Kontoinhaber'); $kontoinhaber->setRule('required'); $form->add($kontoinhaber); // Kreditinstitut $kreditinstitut = new \FrontendForms\InputText('kreditinstitut'); $kreditinstitut->setLabel('Kreditinstitut'); $kreditinstitut->setRule('required'); $form->add($kreditinstitut); // BIC $bic = new \FrontendForms\InputText('bic'); $bic->setLabel('BIC'); $bic->setRule('required'); $form->add($bic); // IBAN $iban = new \FrontendForms\InputText('iban'); $iban->setLabel('IBAN'); $iban->setRule('required'); $form->add($iban); // add the privacy field $privacy = new \FrontendForms\Privacy('privacy'); $form->add($privacy); // add the send copy field $sendcopy = new \FrontendForms\SendCopy('sendcopy'); $form->add($sendcopy); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', 'Absenden'); $form->add($button); if ($form->isValid()) { /** You can grab the values with the getValue() method - this is the default (old) way */ /* $body = $m->title; $body .= '<p>Sender: '.$form->getValue('gender').' '. $form->getValue('firstname').' '.$form->getValue('lastname').'</p>'; $body .= '<p>Mail: '.$form->getValue('email').'</p>'; $body .= '<p>Subject: '.$form->getValue('subject').'</p>'; $body .= '<p>Message: '.$form->getValue('message').'</p>'; */ /** You can use placeholders for the labels and the values of the form fields * This is the modern new way - only available at version 2.1.9 or higher * Big advantage: You do not have to use PHP code and there are a lot of ready-to-use placeholders containing fe the current date, the domain,..... * But it is up to you, if you want to use placeholders or do it the old way * */ $body = '[[TITLE]] [[AUSWAHLVALUE]]<br><br> [[GENDERVALUE]]<br> [[FIRSTNAMELABEL]]: [[FIRSTNAMEVALUE]]<br> [[LASTNAMELABEL]]: [[LASTNAMEVALUE]]<br> [[FIRSTNAME2LABEL]]: [[FIRSTNAME2VALUE]]<br> [[LASTNAME2LABEL]]: [[LASTNAME2VALUE]]<br> [[ADRESSEVALUE]]<br> [[PLZVALUE]]&nbsp; [[ORTVALUE]]<br> [[EMAILVALUE]]<br> [[PHONELABEL]]: [[PHONEVALUE]]<br> [[GEBLABEL]]: [[GEBVALUE]]<br><br> [[KREDITINSTITUTLABEL]]: [[KREDITINSTITUTVALUE]]<br> [[KONTOINHABERLABEL]]: [[KONTOINHABERVALUE]]<br> [[BICLABEL]]: [[BICVALUE]]<br> [[IBANLABEL]]: [[IBANVALUE]]<br><br> // send the form with WireMail $m = wireMail(); if ($form->getValue('sendcopy')) { // send copy to sender $m->to($form->getValue('email')); } $m->to('mail@mail.de')// please change this email address to your own ->from($form->getValue('email')) ->subject('Ein neuer Mitgliedsantrag von ' . $form->getValue('firstname') . ' ' . $form->getValue('lastname')) ->title('<h1>Neuer Mitgliedsantrag</h1>') // this is a new property from this module ->bodyHTML($body) ->sendAttachments($form); if (!$m->send()) { $form->generateEmailSentErrorAlert(); // generates an error message if something went wrong during the sending process } } $content .= $form->render(); echo $content; When selecting the option for "Doppelmitgliedschaft" the fields $name2 ('firstname2') and $surname2 ('lastname2') should appear.
  4. $contacttype = new \FrontendForms\InputRadioMultiple('auswahl'); $contacttype->addOption('Einzelperson'); // 1 person $contacttype->addOption('Doppelmitgliedschaft'); // 2 persons $contacttype->alignVertical(); $contacttype->setRule('required'); $form->add($contacttype); This is to add the Radio-Buttons to my form. Works perfectly. After that I add form-fields for name, surname, adress etc. The working example is living here: https://www.museumsvereincelle.de/der-verein/mitglied-werden/ My idea was to hide certain fields when option 1 is selected (1 Person) and show specific fields when option 2 is selected (2 persons). (Sorry for the complicated description. As the example is in German... )
  5. Thanks for this awesome module!! I am running it on various installations without any issues and flaws! ? Now, a client wants to show form fields only, if the user selected one check box. In the file, I am calling InputRadioMultiple to integrate various buttons. How to I validate for one specific button being checked to show additional form fields? Happy for any input. Thanks a lot!!!
  6. Nice qtguru! I never really looked into twig. I am curious now. ?
  7. Here is the script: #!/usr/bin/php <?php namespace ProcessWire; include("/home/stephan/www/index.php"); foreach ($pages->find("template=post, status=unpublished, sort=unpublished, limit=1") as $post) { $post->removeStatus('unpublished'); $post->addStatus('published'); $post->save(); } With cron it is triggered once a day and it will look for unpublished posts. If there are any, the oldest post will get published. Simple as that. I am using this script to update my photo blog https://photos.stephansimonis.com more regularly. ?
  8. Hi forum, I don't really know how to do this: I want to create multiple (not published but saved) pages. From that on, I want the pages to be published each page a day aromatically. I am sure, this is possible.. But where do I begin? Thanks for suggestions and input. Cheers Stephan
  9. mjut

    Appreciation

    Oh yes! I remember that one!
  10. Alright. It wasn't a MySQL-issue at all! In my search-template I've been using the selector fields incorrectly. I wanted a page-referenece field to be searched and listed. in the selectors I called "pagereference" what I need to do was putting "pagereference.title" into the selectors! Without putting *title after the field, the results were based on searching the url. That led to results I wasnt expecting...
  11. mjut

    Appreciation

    I did revised and recoded my personal blog (journal). It is running with Processwire smoothly since years. A decade ago I started that journal using Textpattern.. So I thought, hey, why not putting it back to Textpattern? I still have a lot of sympathy to Textpattern. Probably because it is the system I learned on.. After setting it all up – it made me giggle every time when I remembered how to do, and work around things – I was happy with the result. After this little travel back in time, I deleted Textpattern again to keep on using Processwire. Nothing else to say. Why am I posting this little story? I dont know... But this might be the right place where people understand what I am saying.. ;) Thanks a lot!
  12. Perfect! Works as it is supposed to do. I just installed the module on my online journal / blog. Keep in mind: encrypted fields are not searchable anymore.
  13. I am experiencing the same issue – changing the collation did not fix it. But maybe it is something different? When searching for Lüneburg the word is being found in all body-fields (textarea) but not in title-fields (the system generated text field). Replacing the Ü with U, I'll get the desired results. Here comes the weird behavior: When searching vor üneburg (umlaut it the beginning of the word) all results with "Lüneburg" in the title-field are being found and listed!!! Isnt that weird? I did look into the database: all tables are set to utf8_general_ci. Changing them to utf8_unicode_ci or even utf8mb4_unicode_ci did not change a thing. I am not sure, where to look into next?
  14. I just used this today – very handy. I specified a template too: wire()->addHookBefore('Page::addable', null, function ($e) { if ($e->object->parents("template=basic-page")->count > 1) $e->object->template->noChildren = 1; });
  15. @Zeka Thank you tons! Yet again, it amazes me how simple Processwire is. I went for the owner selector. Sorry, I did not know about this. The functional code looks like this: <ul> <?php $tags = $pages->find("template=tag, tags.owner.template=post, sort=title"); foreach ($tags as $tag) { ?> <li><a href="<?php echo $tag->url ?>"><?php echo $tag->title ?></a></li> <?php } ?> </ul> As simple as that. I looked it up in the docs, but did not find it – but there is a blog post about Owner Selectors: https://processwire.com/blog/posts/processwire-3.0.95-core-updates/
  16. I am building a web site with a blog / posts section. With each post I create I can add tags. That is happening with a page reference field. For each new tag a new tag (page) will be created. On an "archive" page, I want to list all tags with this code: <ul> <?php $tags = $pages->find("template=tag, sort=title"); foreach ($tags as $tag) { ?> <li><a href="<?php echo $tag->url ?>"><?php echo $tag->title ?></a></li> <?php } ?> </ul> Simple as that, it works as expected. All tags used anywhere in my posts are listed. (yaaay!) But: When creating a new post without publishing, new tags be created and will listed on my archives pages. How can I modify my code to exclude all tags that are associated with unpublished posts? Cheers Stephan
  17. Oh, I wasnt aware, that there's a module. I am sure, this will lead me to a solution. Thanks a lot, this is very helpful!
  18. @dragan thank you for answering! I 100% agree with everything you wrote. (including the multiple posting. that was due to me searching the forum and collectiong information). Usually, I don't need a differnt way of handling a multi-lang site. The processwire way just works and is fine and is straight forward for me. This project I am working on is different. Processwire is providing and delivering the content. But there wont be any UX and no navigation. We will have lots of texts in the museum, each text is accompanied by a QR-Code for the translation into 2–3 languages. (so, QR-Codes all over the museum) The visitors need to scan a QR-Code to get to the specific page containing the translation. To clarify this procedure, I can think of two versions to achieve this. The first one is the usual processwire-way (like in the provided multi-lang-profile). The second one is my desired one, that I need help with. 1. simple solution for each language, there will be one QR-Code (each text in the musuem is accompanied with multiple QR-Codes to choose from) the Visitor scans one of them and the language specific url will be opened conclusion: Each text needs more QR-Codes … one for each language. Thats ugly, and if there will be more language later on, I’d need to add even more QR-Codes… 2. wanted solution there will be only one QR-Code to scan for the visitors, no matter what language - thats much nicer than several QR-Codes the visitor scans that one QR-Code, and will be send to the default language. there will be a lnaguage-switch. So, the visitor can set the desired language. the visitor scans the QR-Code for the next text, the visitor will be directed to the previously set language. (without need to set the language switch again) - if there will be the need to add more languages later on, I can add these in processwire without managing more QR-Codes I hope, this explains the whole project… ? @dragan I like both of your suggestions – the detection of the browsers language and the cookie storage. I did look into the API to set a cookie (session storage?) but I did not understand the techniques described there. No luck for me there… I am going to look into the browser-language detection now. Cheers Stephan
  19. I think, I have the similar question: I need the language-settings being stored into the (guest-)users session. The reason is, the URLs will be openend via an QR-Code. I want the same QR-Codes leading to the (previewsly) selected language by the user. Simply put: 1. the user openes one page via QR-Code. The language can be switched to the desired language. 2. whenever the user openes another page via a different QR-Code, I want processwire to remember the language settings. (depended on each user) does this make any sense? or should i explain that in detail? I already did create a question over here: https://processwire.com/talk/topic/23299-one-url-for-multiple-languages/ Thanks for your help!!!! Cheers Stephan
  20. Hi forum, I have got a question for a multi-language page: English and Danish. I want to give away URLs, no matter if the users language is. www.url.com/en/title1 (default language) www.url.com/dk/title1 If I type www.url.com/title1 the page is being redirected to the default language – even if I previously did chose Danish as my language. Is it possible, that the users prefered language is the redirct? Say, if I choose to view the page in Danish and type www.url.com/title1 I want the redirect to www.url.com/dk/title1 not to the default language. Thanks for suggestions and help Stephan
  21. What do you think of this: https://perishablepress.com/7g-firewall/ ? As I do not know a lot about server configurations, this seems like a hassle-free way to put some layer of security to my websites. What I get from it, I just have to copy these lines provided to my .htaccess file. Edit: It seems to work with my processwire installation: i got the first entry written into the log. (my site got crawled by 360Spider ???)
  22. @Sergio Wow. This is working. I am no php expert. I am always having trouble on this... But I am on my way to get more comfortable on working with variables.... Thanks a lot! <?php $p = $pages->get(1241); if (!$p->isUnpublished()) : ?> <a href="<?php echo $p->url() ?>"><?php echo $p->title() ?></a> <?php endif; ?> yup - tested! The short version works 100%!
  23. Hello, I am having trouble achieving this: I am trying to place a link to a specific page in my template. But I want this link displayed only, if the page is published. With this code, its not working: <?php if ($pages->find("id=1241, status=published")) { ?> <a href="<?php echo $pages->get(1241)->url() ?>"><?php echo $pages->get(1241)->title() ?></a> <?php } ?> (The link is being displayed no matter the status of the page "1241") How can I fix this? Thanks for your help!!!
  24. Thank you for the input! @AndZyk that module is amazing. I fiddled around with it for a bit - the number of tweaks is unlimited! I have to save this for other projects. It seems a bit of an overkill for my needs now. The other approach is exactly what i was looking for! Thank you tons @kongondo - this works like a charm. Cheers Stephan
×
×
  • Create New...