Leaderboard
Popular Content
Showing content with the highest reputation on 10/04/2021 in all areas
-
OK. STEP #1 Create a file, e.g admin.js and save it to your preferred location. In this example, we have saved it at site/templates/scripts/admin/admin.js STEP #2 Add either of the below JS code in admin.js (you don't need both; choose one or the other). jQuery version: $(document).ready(function () { // #wrap_Inputfield_list_price is the ID ProcessWire will assign to your list_price field's wrapper (an li element). // you can confirm this by examining the markup around your 'list_price' input in dev tools. // Inputfields is a utility files that ships with ProcessWire. // more details: inputfields.js - JS specific to behavior of ProcessWire Inputfield forms. Inputfields.focus("#wrap_Inputfield_list_price") }) Plain JavaScript version: const InputfieldAdminScripts = { focusAnInputfield: function (inputfield_id) { const inputfieldToFocus = document.getElementById(inputfield_id) // if we found the element,focus it if (inputfieldToFocus) { inputfieldToFocus.focus() } }, } // DOM ready document.addEventListener("DOMContentLoaded", function () { InputfieldAdminScripts.focusAnInputfield("Inputfield_list_price") // this will also work here. you can use it instead of the above // Inputfields.focus("#wrap_Inputfield_list_price") }) STEP #3 Inside ready.php, add this code to load admin.js. You can modify this to only load under certain conditions if you wish. <?php namespace ProcessWire; $this->addHookBefore('AdminTheme::getExtraMarkup', function (HookEvent $event) { $config = $this->wire->config; $url = $config->urls->templates; $config->scripts->add($url . "scripts/admin/admin.js"); }); Please note that in Chrome (and maybe FF as well), if you have your dev tools opened and the cursor currently focused on it, the inputfield might not seem to be focused, but it actually is. ?2 points
-
@Siddhi Jagtap u.file perms is no write. /site/assets/* need tobe readerable/writedable to.apache sound like apache .run as account that.not you - mabe find new web host that less truble or u.can find out.user what apache run as - "apache", "nobody", "buldnog", etc. if user "apache": https://processwire.com/docs/security/file-permissions/#determining-what-user-apache-runs-as chgrp -R apache /site/assets find /site/assets -type d -exec chmod 775 {} \; find /site/assets -type f -exec chmod 664 {} \; https://processwire.com/docs/security/file-permissions/#how-to-change-permissions-of-existing-files but also visitarlos cont'la lachpud may helper - https://processwire.com/docs/security/file-permissions/2 points
-
Understood. To make dealing with this particular case easier, do you think we add parameters to ___pageNotAvailableInLanguage() method which defines what page the redirect will lead to and what http code will it be. Or do you suggest to replace the whole method in this case?2 points
-
Hello @ all I want to share a new module with you, which makes the creation and validation of forms easy. Take a look at the following example of a simple contact form: // A very simple example of a contactform for demonstration purposes $form = new Form('contactform'); $gender = new Select('gender'); $gender->setLabel('Gender'); $gender->addOption('Mister', '0'); $gender->addOption('Miss', '1'); $form->add($gender); $surname = new InputText('surname'); $surname->setLabel('Surname'); $surname->setRule('required'); $form->add($surname); $name = new InputText('name'); $name->setLabel('Name'); $name->setRule('required'); $form->add($name); $email = new InputText('email'); $email->setLabel('E-Mail'); $email->setRule('required'); $form->add($email); $subject = new InputText('subject'); $subject->setLabel('Subject'); $subject->setRule('required'); $form->add($subject); $message = new Textarea('message'); $message->setLabel('Message'); $message->setRule('required'); $form->add($message); $privacy = new InputCheckbox('privacy'); $privacy->setLabel('I accept the privacy policy'); $privacy->setRule('required')->setCustomMessage('You have to accept our privacy policy'); $form->add($privacy); $button = new Button('submit'); $button->setAttribute('value', 'Send'); $form->add($button); if($form->isValid()){ print_r($form->getValues()); // do what you want } // render the form echo $form->render(); This piece of code creates a simple contact form and validates it according to the validation rules set. Inside the isValid() method you can run your code (fe sending an email) Highlights: 30+ validation types Support for UiKit 3 and Bootstrap 5 CSS framework SPAM protection Highly customizable Hookable methods for further customization Multi-language You can download and find really extensive information on how to use at https://github.com/juergenweb/FrontendForms. Please report errors or suggestions directly in GitHub. Best regards and happy testing ? If you have downloaded the module in the past I recommend you to uninstall the module completely and install the newest version 2.1.14. There are a lot of changes in the new version, so please test carefully.1 point
-
That's strange. Somewhere along the way, PagePathHistory::__upgrade should have been triggered and added that column. The language_id column was introduced with version 2 of the module, shortly before PW was moved to the new GitHub repo in 2016. There was an identical issue mentioned back then, and Ryan added a self-healing fix in PagePathHistory::getPath, but it looks like he took that out after a few years. You can, however, add that column manually to get rid of the error and put the language_id back into the select: ALTER TABLE page_path_history ADD language_id INT UNSIGNED DEFAULT 01 point
-
To focus an Inputfield there is a method since 3.0.145 (ProcessWire 3.0.145 core updates) Inputfields.focus(f) which you could put into an custom admin.js file. There is also a possibility to do a redirect and focus the field via PHP but I don't remember the query parameter. Maybe @bernhard can jump in for the correct syntax.1 point
-
Hello @Flashmaster82, There are different ways - the most simple one is to use PWs built in Mail class: Here is a working example (not tested but it should work ;-)) $form = new Form('contactform'); $gender = new Select('gender'); $gender->setLabel('Gender'); $gender->addOption('Mister', '0'); $gender->addOption('Miss', '1'); $form->add($gender); $surname = new InputText('surname'); $surname->setLabel('Surname'); $surname->setRule('required'); $form->add($surname); $name = new InputText('name'); $name->setLabel('Name'); $name->setRule('required'); $form->add($name); $email = new InputText('email'); $email->setLabel('E-Mail'); $email->setRule('required'); $form->add($email); $subject = new InputText('subject'); $subject->setLabel('Subject'); $subject->setRule('required'); $form->add($subject); $message = new Textarea('message'); $message->setLabel('Message'); $message->setRule('required'); $form->add($message); $privacy = new InputCheckbox('privacy'); $privacy->setLabel('I accept the privacy policy'); $privacy->setRule('required')->setCustomMessage('You have to accept our privacy policy'); $form->add($privacy); $button = new Button('submit'); $button->setAttribute('value', 'Send'); $form->add($button); if($form->isValid()){ // send an email $m = wireMail(); $m->to('myEmail@test.com); // enter here the email address where the mail should be sent to - usually it is your email address $m->fromName($form->getValue('gender').' '.$form->getValue('surname').' '.$form->getValue('name')); $m->from($form->getValue('email')); // the email address of the sender $m->subject($form->getValue('subject')); // the subject of the email $m->bodyHTML($form->getValue('message')); // the message text of the email $mailSent = $m->send(); // optional check if there was an error sending the mail // true on success, false on failure if(!$mailSent){ $form->getAlert()->setText('There was an error sending the mail.'); $form->getAlert()->setCSSClass('alert_dangerClass'); } // save the email as page $p = new Page(); // create new page object $p->template = 'email'; // set template -> you have to create the template first by yourself $p->parent = wire('pages')->get('template=contact'); // set the parent page $p->title = $form->getValue('subject'); $p->body = $form->getValue('subject'); $p->save(); } // render the form echo $form->render(); To send an email please check the docs at https://processwire.com/api/ref/wire-mail/ By creating a new page to save the email as a page under the contact form page please take a look at "save the email as page" section in the code above. You have to create the template and the fields for the email template first by yourself. 1) Create a template with fe the name 'email' first 2) Add the fields to the template where you want to store the data of the email (fe surname, name, subject, email address, message,....) 3) You have to set the parent page finding the parent by its template name (in the above example the contact form page uses the template 'contact') 4) Add the mail values to the email template fields and save the page. Best regards1 point
-
Sorry for my late response, I am more interested in other things right now. There are some great discussions about layout builders at the moment, that I have to catch up and I find it great, because all those new API methods and modules are great, but for me more important is how content can be more flexibel for clients. ? Since you want to here my opinion on this topic: This demo is looking great for a proof of concept and funny thing is, that I had to work with the YOOtheme builder on a WordPress website a month before and thought myself: This is a nice layout builder. Especially how you can make new sections with grids, duplicate them and so on. And all with a live preview. ? One downside was, that you have some many options in the YOOtheme builder to build your own layouts, that it can be confusing some times and you have to search for a few minutes. As for your proof of concept: It is really nice, but if the data would be stored only in the module, I would not use it. Because if something changes in ProcessWire (maybe in version 4) or you would not update the module anymore, I would have to migrate tons of data in the core fields again. I try to build websites with core fields only, that are still working in years and I had to work with projects before, where everything was build around a module that didn't got support be the third-party developer anymore. If it would be possible to combine the power of ProcessWire and its custom fields inside a layout builder field, where the data still would be there without the layout builder field, that would be awesome. So the layout builder would just be an enhancement of the existing structure, instead of the whole structure. I think I will wait for Ryans take on this and you are probably still busy with Padloper 2, but thank you for this proof of concept. It is nice to have people like you, that are driving ProcessWire forward. ? Regards, Andreas1 point