Jump to content

MatthewSchenker

PW-Moderators
  • Posts

    677
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by MatthewSchenker

  1. Hey renobird, Late here too, but difficult to sleep when working on a ProcessWire site! You are correct... I was missing that piece! Definitely, that should be there. I added it, and holding my breath I tried the form again. But it still doesn't work. Same result: no errors, and we see the "success" page, but the new page does not appear in the page tree. Other suggestions or ideas? Thanks, Matthew PS: I've edited my post above to keep track of changes. That way, when this discussion is done, there will be a complete example for others to reference.
  2. Hey Wanze, Yes, that shows you have a good eye for sure! Unfortunately, that was just an error from me transferring the text to the forum... I edited the forms in my first post and fixed that word. In other words, it still doesn't work. Any other ideas? Thanks, Matthew
  3. Greetings Everyone, ************************************************* ************************************************* EDIT NOTE: This post started as a work-in-progress discussion as I was working out the elements of a successful form. After contributions from participants in this discussion, the code below has been tested and works well. You can use the code as shown below in your ProcessWire templates! Feel free to follow up with additional quesations/comments! ************************************************* ************************************************* I have successfully built front-end forms with ProcessWire to add pages via the API. It works great -- until I had to include image uploads along with the "regular" form fields. Then it temporarily got a bit complicated. In this discussion, I show how to handle front-end submissions in ProcessWire with the goal of allowing us to create pages from custom forms. I then go a step further and show how to use the same form to upload files (images and other files). I'm hoping this discussion can illustrate the whole process. I know a lot of people are interested in using ProcessWire to do front-end submissions, and my goal for this discussion is to benefit others as well as myself! First, here's my original contact form (no file uploads): <form action="/customer-service/contact/contact-success/" method="post"> <p><label for="contactname">Name:</label></p> <p><input type="text" name="contactname"></p> <p><label for="email">E-Mail:</label></p> <p><input type="email" name="email"></p> <p><label for="comments">Comments:</label></p> <p><textarea name="comments" cols="25" rows="6"></textarea></p> <button type="submit">Submit</button></form> And here's the "contact-success" page that picks up the form entry to create ProcessWire pages: <?php // First, confirm that a submission has been made if ($input->post->contactname) { // Save in the ProcessWire page tree; map submission to the template fields $np = new Page(); // create new page object $np->template = $templates->get("contact_submission"); $np->parent = $pages->get("/customer-service/contact-us/contact-submission-listing/"); // Send all form submissions through ProcessWire sanitization $title = $sanitizer->text($input->post->contactname); $name = $sanitizer->text($input->post->contactname); $contactname = $sanitizer->text($input->post->contactname); $email = $sanitizer->email($input->post->email); $comments = $sanitizer->textarea($input->post->comments); // Match up the sanitized inputs we just got with the template fields $np->of(false); $np->title = $contactname; $np->name = $contactname; $np->contactname = $contactname; $np->email = $email; $np->comments = $comments; // Save/create the page $np->save(); } ?> This works great! After submitting the form, we go to the "Success" page, and new submissions show up in the ProcessWire page tree right away. Excellent! Now I need to add a photo field. I altered the above form so it looks like this: <form action="/customer-service/contact/contact-success/" method="post" enctype="multipart/form-data"> <p><label for="contactname">Name:</label></p> <p><input type="text" name="contactname"></p> <p><label for="email">E-Mail:</label></p> <p><input type="email" name="email"></p> <p><label for="comments">Comments:</label></p> <p><textarea name="comments" cols="25" rows="6"></textarea></p> <p>Click the "Select Files" button below to upload your photo.</p> <input type="file" name="contact_photo" /> <button type="submit">Submit</button> </form> And here's the updated "contact-success" page: <?php // First, confirm that a submission has been made if($input->post->contactname) { // Set a temporary upload location where the submitted files are stored during form processing $upload_path = $config->paths->assets . "files/contact_files/"; // New wire upload $contact_photo = new WireUpload('contact_photo'); // References the name of the field in the HTML form that uploads the photo $contact_photo->setMaxFiles(5); $contact_photo->setOverwrite(false); $contact_photo->setDestinationPath($upload_path); $contact_photo->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); // execute upload and check for errors $files = $contact_photo->execute(); // Run a count($files) test to make sure there are actually files; if so, proceed; if not, generate getErrors() if(!count($files)) { $contact_photo->error("Sorry, but you need to add a photo!"); return false; } // Do an initial save in the ProcessWire page tree; set the necessary information (template, parent, title, and name) $np = new Page(); // create new page object $np->template = $templates->get("contact_submission"); // set the template that applies to pages created from form submissions $np->parent = $pages->get("/customer-service/contact-us/contact-submission-listing/"); // set the parent for the page being created here // Send all the form's $_POST submissions through ProcessWire's sanitization and/or map to a variable with the same name as the template fields we'll be populating $np->title = $sanitizer->text($input->post->contactname); $np->name = $np->title; $np->contactname = $sanitizer->text($input->post->contactname); $np->email = $sanitizer->email($input->post->email); $np->comments = $sanitizer->textarea($input->post->comments); $np->save(); // Run photo upload foreach($files as $filename) { $pathname = $upload_path . $filename; $np->contact_photo->add($pathname); $np->message("Added file: $filename"); unlink($pathname); } // Save page again $np->save(); ?> <p>Thank you for your contact information.</p> <?php return true; } else { ?> <p> Sorry, your photo upload was not successful...</P> <?php } ?> Replace the field references with your own field names, make sure to change the various paths to match yours, and change the various messages to be what you need for your project. Read the entire discussion to see how we worked through getting to the solution shown above. Thanks, Matthew
  4. Greetings, Following this discussion... I have successfully built PW pages from front-end form submissions, but seem to be having trouble with having a file upload field as part of the overall form. FuturShoc: if possible, can you post the code you used for the entire Member Profile template? I think it would help to see the file-upload portion of the form in the context of the whole form. Thank you very much! Matthew
  5. Greetings, Excellent post Ryan! I wish the forum had a "Like Very Much" button! Thanks, Matthew
  6. Hi Basil, You just want to use it to display ProcessWire content? If so, the procedure is very similar to what I posted here regarding FlexSlider: http://processwire.com/talk/topic/3032-photo-gallery-site/#entry29886 Give some more details in your question, and we can provide more detailed answers! Thanks, Matthew
  7. Greetings Basil, Putting together a slider is just a few steps in ProcessWire. Check out the tutorial I wrote on how to do this with Galleria (the steps are the same for Flexslider): http://processwire.com/talk/topic/2533-first-site-first-problem/page-2#entry24929 It's very exciting to know you can make these things work so nicely, and ProcessWire allows us to have that excitement over and over again! Let me know if you have other questions. Thanks, Matthew
  8. Greetings, As Soma explained, you can turn off the need for the title field. However, I would want to make sure this is a good idea. If you ever need those pages for other purposes, you'll likely want the title. Also, the "title" can be anything (any field). It does not need to be an extra field, and the user does not even have to know that it's a "title." For example, I'm working on a site with separate pages for numerous retail stores. Stores each have a unique "store number," and I just made that the "title." The user does not know that when they enter the store number they are simultaneously creating a "title," but now I have that bit of information to use in my template code. Based on your description, it sounds like your users are already building invoices through field entries. Maybe just use the "invoice_number" field as the title? Thanks, Matthew
  9. Greetings chris, Thanks for sharing! I really like the vibrant feeling of your portfolio site! I'm viewing it on the iPad and it looks great -- easy and clear navigation, with bold statements that stand out but remain tactful. Terrific balance. Couple of comments (viewed on iPad): This page -- http://chrisvaupel.de/referenzen/ -- feels a bit squashed. Perhaps it needs a slightly better division between the text and graphics? This page -- http://chrisvaupel.de/leistungen/ -- has big icons that react when "touched," but don't actually do anythng. Is ths intentional? Thanks again, Matthew
  10. Hey Marty, Just checked the site again and all the pages are perfect in the viewport! Problem solved. Thanks, Matthew
  11. Hey Marty, I just captured the 7 main screens on my iPad with Safari and sent them to you. You will see that some are good and others are outside the viewport. That leads me to think it should be pretty easy for you to fix! Let me know if the screen shots arrive OK. Thanks, Matthew
  12. Hey Marty, I'm using the latest iPad. Interesting that there would be a difference. Would be curious to hear from others. Thanks, Matthew
  13. Greetings, Excellent work! Really like the bold colors and immediate sense of what the site is about right from the home page. Great deaign concept. My experince is the same as Alex's -- site loads really fast. One comment: some pages don't size quite right on the iPad and require scrolling to the right to see important content. On the "EM's Guides" page, when you choose a lettered index at the top, the only thing that changes is on the far right. This is OK on a desktop, but on an iPad it appears as though nothing is changing until you scroll to the right. By contrast, the "How to Plan an Event" and the "About EM" pages are sized correctly on the iPad. I tested this on iPad Safari and Chrome. Thanks for sharing! Matthew
  14. Greetings, Thanks adrian for the post. I like Swiftmailer, and find it to be a very neat library with great documentation. It's so easy to use that I think perhaps just a set of instructions for including the library in our projects would be good enough. Or -- as Pete said -- it could be made into an optional module. Definitely, I like the concept that these things are left out of the core. That way, everyone can choose their own path. Thanks again, Matthew
  15. Greetings Jennifer, Wow -- terrific, amazing, impressive work! And thanks for the write-up. A lot of what you say is exactly the way I feel about using ProcessWire, especially the idea of being able to do in a month what used to take several months (or was impossible) with other systems. And I see exactly what you mean about building systems that empower clients. But let's not get hit by a bus, because even though clients can manage sites after you build them you are still needed to build NEW sites! I've been looking at Foundation, but have been on the fence regarding CSS/JS frameworks. But I am feeling lately that it's time to jump in. Thanks for sharing, Matthew
  16. Greetings owzim, Your story is very familiar. Seems that more and more people are "tinkering" with ProcessWire and very quickly realizing how intuitive the API is and how much we can accomplish with this system. As others have said, this community is one of the best aspects of ProcessWire. Post your questions, and watch what happens! Thanks, Matthew
  17. I assume Ryan was referring to WordPress, Drupal, and Joomla. Thanks, Matthew
  18. Greetings Luis, Excellent work! I hope lots of people purchase it! This is a great inspiration to anyone working on building various applications with ProcessWire. Thanks, Matthew
  19. Greetings ChrisKB, Do you mean using forms to create pages? If so, there are lots of good ways to do it. Just give us a bit more information and you can get answers! Thanks. Matthew
  20. Greetings, Thanks Ryan! This opens the door to some ideas that have come up in various forum discussions... With this module, it seems we are getting close to being able to create pages of any kind by sending an e-mail with the right bits to our ProcessWire installation. Maybe along with each site, we could create e-mail templates with reserved spots like <<title>>, <<name>>, <<body>> and other fields. Then (if I am on the right track) we just need a way to pick up whatever is in those reserved bits as variables in the page-creation process! I've been using the ProcessWire API to create pages and this seems like a potential extension of that process. Thanks, Matthew
  21. Gretings Georgson, Thanks for sharing, and congratulations on the launch! Seems that ProcessWire helped you zoom to a great finish. I like the site. The colors present a positive, active sensation throughout the site. The photos on all the slideshows are very professional. I'm viewing the site on an iPad (I'll check from a desktop later). My only comment would be -- if possible -- to make each project a bit more distinct as you scroll down the page. Thanks again for sharing, Matthew
  22. Greetings, And by coincidental coincidence, I heard a BBC interview just a couple of days ago with someone from the Gates Foundation, and on Friday I was playing with some Windows 8 laptops. Thanks, Matthew
  23. Hey Everyone, ... At my desk working... Dark in the room. I was very nearly done with the project and feeling pretty good. Then I noticed something moving along the ceiling, coming closer to me. At first, I thought it was a bit of fuzz. Then I realized it was a very large mosquito. It came right to my computer and settled on top of the screen, taunting me. I turned back to my code. Thanks, Matthew
  24. Greeting All, Thanks Ryan! See, that's what I like so much about ProcessWire: in one paragraph of straightforward language, you explain something that takes a series of confusing graphics in other systems. Thanks, Matthew PS: It seems, perhaps, that ProcessWire challenges the notion that a picture is worth a thousand words!
  25. Hey Joss, I am thinking along these lines as well. Maybe we can work together on a neat system. I'll have some time to work on things like this soon... For the moment, I just could not resist your comment about Joomla's rights system. I am sharing some images so everyone here can sympathize with what you and I had to deal with before coming to ProcessWire... WARNING: THESE IMAGES ARE NOT FOR ANYONE WITH NERVOUS OR ANXIOUS TENDENCIES. http://docs.joomla.org/File:Screenshot_acl_tutorial_20110111-07.png http://docs.joomla.org/File:Screenshot_acl_tutorial_20110111-16.png http://docs.joomla.org/File:Acl_example_diagram1_20091018.png Thanks, Matthew
×
×
  • Create New...