Jump to content

All Activity

This stream auto-updates

  1. Today
  2. Hi @wishbone Try change the following line to "Reply-To:" . $form[email] . "\r\n" . Gideon
  3. Yesterday
  4. Thank you really with include=all everything works and shows well. As for your first question, this page is available for viewing. I have a part of the assortment of the cafe displayed on the main page. The administrator puts a check mark that this element should be shown. That's all.
  5. Great idea @Anonimas I have integrated both. You can change/customize the text for the required fields with setRequiredText() method. $form->setRequiredText('This is my customized text, that you have to fill out all required fields.') I have also added EOT for better readability. Please download and install the module once more. Thanks for your ideas.
  6. thx, DV-JF, for looking into this! Now Reply-To is empty... From: info@selfdomain.com Reply-To: X-Mailer: PHP/8.1.5
  7. With adding ".PHP_EOL;" after every field on $form->render() would help reading page source easier, because now all form is one long line.
  8. Hi, I'm using https://html5up.net/story template and want to use unmodified css file. It wraps all form fields for inline fields alignment (name and email in example) and css use "form > .fields > .field ". If Div with class "fields" is outside form, then it don't works. I tested with new version and it works! Thank you for update! Also it would be useful to add something like setRequiredText(), because now I disabled default and added my text manually before form. Something like setErrorMsg() and setSuccessMsg().
  9. Hi @siaweb, Do visitors have access to the pages of the "assortment_name.home_menu=1" selector? Did you try with include=all in the find()? Looks like an issue of access control: https://processwire.com/docs/selectors/#access_control I personally think it would be better to resolve the access of the pages instead of using include=all, but you do you 🙂
  10. Good afternoon, I can't solve the problem. This block is invisible to unregistered users. And we need everyone to see it. Who will have any thoughts?
  11. Hi @Jan Fromm, Thanks for reporting this. Nope. Entirely my silly mistake. Nothing to do with your setup or Tracy 😁. Forgot a 'check_access=0' in the selector to grab the line item to delete (since they are in admin). So, the reason it worked with 'Tracy enabled' is, I guess, you were logged in as a Superuser :-). Anyway, sorted for now. Please grab the updated files again. Not at all 🙂. Thanks.
  12. Hi all. This is where my lack of actual PHP knowledge is getting to me. I've inherited a never-completed WordPress website that I'm trying to redo in PW. There are products, categories and product options all supplied as separate CSV files. (These will be edited and uploaded every day, so I will need to eventually import the data with a chron script). Importing and displaying the category and product data isn't a problem, but the product options files contains numerous fields with comma- and pipe-delimited strings which need to be converted into arrays. So, when viewing the product-page (template) for 'Chair 123' (product code 'c123'), I'd normally get all the options like '$options = $pages->find('template=options-page, pcode=c123'); But since there are fields in the options-page that look like "505|501|512" (for color codes), I'll need to get these into an array. Thats' very simplified; the actual options page has about 45 fields, used to present various options in 3 worldwide territories with multiple parts/color combinations for each conditional territory! I should also mention that I have the old WordPress site and can see the custom functions the previous guy had set up and (for me) it's very complicated. Most of it is standard PHP, so I was hoping to use much of it 'as is' as I can. For instance, there's a function on the products page that returns an associative array that looks like this (in the WordPress php): $bt_options = bt_get_product_options($entry["code"]); foreach($bt_options['spec_docs'] as $key => $bt_spec_doc) { $bt_show_download = ""; if($bt_options['spec_docs_territory'][$key] == "E" && $bt_this_territory == "EU") { $bt_show_download = "Y"; } elseif($bt_options['spec_docs_territory'][$key] == "U" && $bt_this_territory == "US") { $bt_show_download = "Y"; } ... } And the bt_get_product_options function starts with this (again from WordPress) function bt_get_product_options($id) { global $wpdb, $bt_colours, $mysql_table; $entriesList = $wpdb->get_results("SELECT * FROM ".$mysql_table['options']." WHERE web_product_code = '".$id."' ORDER BY id ASC LIMIT 1"); $entriesList = json_decode(json_encode($entriesList), true); /// CONVERT TO STANDARD ARRAY if(count($entriesList) > 0){ $output = array(); $output['jquery'] = ""; foreach($entriesList as $entry) { ... /// COMBINATION TERRITORY elseif($key == "comb_territory" || $key == "addnl_subtabs_territory" || $key == "spec_docs_territory"){ $ter_array = explode("|", $tt); foreach ($ter_array as $k => $tr) { $output[$key][] = $tr; } } ... loads more like this ... } } return $output; } TL;DR: Can I use the above in my PW code, provided I swap the WP MySQL bit with $entriesList = $(wire)pages->find("template=options-page, product_code=$id, limit=1) ? (I tried this on a limited set of fields but didn't return anything). Or do I need to do a MySQL request too? And from what I can tell, thet json_decode/encode line should covert the page object to an associative array, correct? Should that work in this case? Thanks for reading this far.
  13. $headers = 'From: info@selfdomain.com' . "\r\n" . 'Reply-To: '.$email . "\r\n" . 'X-Mailer: PHP/' . phpversion(); This should help 😉
  14. problem how to set headers "from" correctly Important change due to DMARC-policies: If the user's email contains e.g. yahoo or hotmail, it will be rejected. -> "From" - never set user's email To be able to reply to the user's email nevertheless, set headers. $headers = 'From: info@selfdomain.com' . "\r\n" . 'Reply-To: $email' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); throws: "Reply-to: $email" (everything else is correct) tried: 'Reply-To: $form[email]' . "\r\n" . also only gives the string "$form[email]", doesn't run the code. $email is: $form = array( ... 'email' => $sanitizer->email($input->post->email), ... ); Where is my syntax error? thx again!
  15. Hi @kongondo, Thanks again for your quick help and customization of the module. Unfortunately I have to ask another stupid question, which probably has nothing to do with Padloper, but with my setup. I installed your update and added the new parameter. Now the product is deleted from the cart and the order, but only when Tracy Debugger is active. When I test without Tracy Debugger, only the cart is updated, but not the order. I have refreshed the module several times, and also cleared the cache with Cache Admin. Still, the updated code doesn’t seem to be applied in every context. Sorry to bother you again with such small stuff.
  16. Sorry, just solved it, I had two consecutive Ajax request, hence the duplicate entries.
  17. The labels are settings/properties of InputfieldSelectImages so you would need to customise them there rather than via FieldtypeDynamicOptions. You'd use a hook like this: $wire->addHookAfter('InputfieldSelectImages::renderReadyHook', function(HookEvent $event) { $inputfield = $event->object; $field = $inputfield->hasField; $page = $inputfield->hasPage; // Some test here using $inputfield/$field/$page $inputfield->label_unavailable = 'This is my custom label.'; }); The styling is based on the core InputfieldImage, and rightly or wrongly the equivalent icon there is centered within the button, excluding the thumbnail border. So I don't want to change from that generally. But now that the icon has been changed to a cross instead of the earlier trash icon it does look like it could come up a couple of pixels so I've done that. Of course you can always tweak the styling to your liking with custom CSS as you're doing. Done.
  18. As a note, in the Tracy debugger it works but as soon as I make an ajax call there is a duplicate entry.
  19. Hello, I have a problem when saving repeater. When I do the following I always have a duplicate entry. $notification = $user->notifications->getNew(); $notification->messageid = $arr_data['messageid']; $notification->notificationid = $arr_data['notificationid']; $notification->users = $arr_data['userid']; $notification->date = time(); $notification->save(); $user->notifications->add($notification); $user->save(); What am I doing wrong? Thanks for feedback
  20. Hi Anonimas Inspired by your question I have added a new method to add the wrapper div over all form fields (including hidden fields too). $form->setFormElementsWrapper()->setAttribute('class', 'mycustomclass'); By default a unique CSS id will be added, but as you can see in the example above, you can also add a class attribute (or other attributes) too. <form> <div id="formelementswrapper" class="mycustomclass"> .... </div> </form> To use this method, please download version 2.0.9 from GitHub. Alternatively replace the Form.php. This file includes all the changes and additions. BTW could you please tell me, what is the intention for you to wrap all form fields in an extra div? Best regards Jürgen
  21. Hi Anonimax Yes it is possible, but instead of adding the divs to the form element itself you have to add the opening div to the first form element and the closing div to the last form element. Please take a look at the example code below: $form = new \FrontendForms\Form('testform'); $surname = new \FrontendForms\InputText('surname'); $surname->setLabel('Surname'); $surname->setRule('required'); $surname->getFieldWrapper()->prepend('<div>'); $form->add($surname); $email = new \FrontendForms\InputText('email'); $email->setLabel('E-Mail'); $email->setRule('required'); $email->setRule('email'); $form->add($email); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', 'Send'); $button->append('</div>'); $form->add($button); if($form->isValid()){ print_r($form->getValues()); // do what you want } // render the form echo $form->render(); The first input field in the form is the text input "surname". Grab the field wrapper object and prepend the div there: $surname->getFieldWrapper()->prepend('<div>'); The last element in this form is the button element -> so append the closing div there: $button->append('</div>'); It always depends on the structure of your form. Hidden fields are excluded in this case from beeing wrapped with the div, but I guess this should not be a problem. If you have problems, please post your form code here. Best regards
  22. Last week
  23. Hi @Robin S, Thank you very much for your modules! With this I managed to create a simple conditional visual page selector. For anyone interested: $wire->addHookAfter('FieldtypeDynamicOptions::getSelectableOptions', function(HookEvent $event) { /** @var Page $page */ $page = $event->arguments(0); /** @var Field $field */ $field = $event->arguments(1); if($field->name === 'artworks') { $artists = $page->artists; // Page-reference field $options = []; foreach($artists as $artist) { foreach($artist->children() as $artwork) { if(!$artwork->gallery->count()) continue; $inputfield = $artwork->getInputfield("gallery"); $thumb = $inputfield->getAdminThumb($artwork->gallery->first()); $options[$artwork->id] = [ "label" => "$artwork->title, $artwork->year", "attributes" => [ "data-thumb" => $thumb["thumb"]->url ] ]; } } $event->return = $options; } }); + with the added bonus of being able to customize labels it works great. A question and a suggestion: Based on some condition (eg: if no artist is selected), it'd be nice to be able to display a specific message other than the "Unavailable" label using the hook (for the Dynamic Options module in general) A teeny-tiny css edit: put the clear button at top: 0 and left: 0, and add a padding: 6px to the label <div>
  24. thx @szabesz Hi @Andy thx for your kind words! well... I like to do thinks in code rather than clicking around a GUI, because then I have all in GIT and can automatically deploy it to production. In addition to that I love how you can write form code once and get frontend and backend validation of your forms automatically. The next point is that I don't like the embed methods via Iframe and I never got used to the other output method - how is it called? Direct output? Another point is that I try to avoid hook hell as much as possible. Hooks are great, but I started to adopt concepts where things that belong together are in the same file or folder. That's why every form that I create for RockForms is one single PHP file, that defines all the necessary pieces (fields, after submit action like sending an email, markup for the frontend, error messages...). <?php namespace ProcessWire; /** @var RockForms $rockforms */ $form = $rockforms->form('newsletter', [ 'token' => false, // disable csrf for use with procache! ]); $form->setMarkup("field(email)", "<div class='sr-only'>{label}</div>{control}{errors}"); $form->getElementPrototype()->addClass('mb-12'); $form->addText("email", "E-Mail Adresse") ->setHtmlAttribute("class", "text-gray-dark w-full focus:border-violet focus:ring-violet") ->setHtmlAttribute("placeholder", "Ihre E-Mail Adresse") ->isRequired(); $form->addMarkup("<button type='submit' class='btn btn-sm btn-pink !px-12 mt-6'>Newsletter abonnieren</button>"); if($form->isSuccess()) { $values = $form->getValues(); if($form->once()) { /** @var RockMails $mails */ $mails = $this->wire('modules')->get('RockMails'); $mails->mail('newsletter') ->to('office@example.com') ->subject("New Newsletter Subscription") ->bodyHTML($form->dataTable()) ->send(); $this->log('sent mail'); } $form->success('<span style="color:black;">Thank you for your subscription</span>'); } return $form; This is an example for an easy newsletter subscription form. For me it is also better to code my own module because then I have a lot more freedom and can add extensions and new features while working on any project that uses the module. For example the $form->dataTable() is something I need very often (send form data via mail or show form data in the backend). I guess I'll release this as commercial module soon - if anybody reads this and is interested in a closed alpha write me a PM 🙂
  25. Hi, Is there a way to insert <div> inside <form></form>? I need to wrap all input fields, but addFieldwrapper() or $form->prepend() does not fit here. It works with str_replace, but then $tmp=form->render() doubles output.
  26. I am trying to get some sites to remain in Unpublished status until certain conditions are met. However, I have a problem with the message ProcessPageEdit: Published Page. Overall, wire()->addHookAfter("Pages :: saved") seems to work for existing pages. And I can put them into Unpublished status whenever I want after I have saved them. But when creating a new page, the order of events is different. The newly created page is set to Published status when someone clicks Publish in the second step of the page adding process. But it runs after my code. How to solve this problem? Is there any documentation about the order of events?
  27. Thanks!, I edited my post above while you responded. In the mean time I've realized that my misunderstanding is that I can't replace parent regions, then the child regions will be destroyed. Like, I can't have this and update both foo and bar directly using replacement <div id="region1"> foo <div id="region2"> bar </div> </div> i would have to do <div id="region1"> <div id="region1inner"> foo </div> <div id="region2"> bar </div> </div> However, as you suggest, I can add to the parent like (using the code from my previous post) <div id="maincontent" pw-append> added this to main </div> <div id="testregion"> replaced </div> ..as long as i don't replace the whole parent. This makes sense, since I suppose this is some form of string replace behind the scenes awesome, and thanks again Ryan! J
  1. Load more activity
×
×
  • Create New...