Jump to content

pwired

Members
  • Posts

    2,318
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by pwired

  1. Just follow this thread out of many: https://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/
  2. Welcome and Hats off for what you are doing Mauricius. I thought I already saw them all out there. But jssor ? Really amazing !
  3. Aha, so this is what they mean with decoupled cm-systems.
  4. I see that this line of code is used: $contact_photo->error("Sorry, but you need to add a photo!"); If I go to http://cheatsheet.processwire.com and look in the api cheatsheet, I see nowhere the part: ->error Where can I find more about ->error and how to use it with api ? Edit: I found something here: https://processwire.com/talk/topic/4659-customizing-error-messages-for-inputfields/ https://processwire.com/talk/topic/1126-how-to-debug-use-the-error-log/
  5. Of course, the part: else { echo "<p>Sorry, your photo upload was not successful...</P>"; } will always be true in the beginning as long as the form has not been submitted and so the message: Sorry, your photo upload was not successful... will always show up in the beginning.
  6. Mucho thank you LostKobrakai. Your changes made me end up with an error message that at least made me know what to do. Parse Error: syntax error, unexpected '<' (line 75 of site\templates\form.php) Adding ?> after the last } in: }else { echo "<p>Sorry, your photo upload was not successful...</P>"; } so it looks like this: }else { echo "<p>Sorry, your photo upload was not successful...</P>"; } ?> Made the error go away and now the form shows up. A major step forward. I guess normally it should not be needed to put there ?> but in my case without it, that last error message comes back ! Also the message: Sorry, your photo upload was not successful... shows up in all cases, all the time. Anyway it has come alive, so from here I should be able to go on with it. Thanks.
  7. Edit: When I remove the comment: // First, confirm that a submission has been made in the first line of the code I get this error message: Parse Error: syntax error, unexpected end of file (line 98 of \site\templates\form.php) Line 98 is the very last empty line in my editor
  8. Hi, I am studying forms and form processing with processwire. I found this post in a thread with very good information about it: https://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/page-4#entry39669 Thing is I can't get the code to work that is posted there because as far as I can see the last part of the code is not closed correctly. Also my editor shows that the last part of the code is not close correctly. Looks like a curly bracket or a ?> is not on the right place. Tried everything but can't find it. Maybe I am missing something ? This is the last part of the code where I think a mistake is causing it not to work: // 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} ?> And here is the complete code: <?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'); // Reference field name in HTML form that uploads photos $contact_photo->setMaxFiles(5); $contact_photo->setOverwrite(false); $contact_photo->setDestinationPath($upload_path); $contact_photo->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); // Second wire upload (other_photos) [NEW CODE] $other_photos = new WireUpload('other_photos'); // Reference field name in HTML form that uploads photos $other_photos->setMaxFiles(10); // Allow 10 other photos $other_photos->setOverwrite(false); // Use the temporary location set above $other_photos->setDestinationPath($upload_path); $other_photos->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); // execute upload and check for errors $files = $contact_photo->execute(); $other_files = $other_photos->execute(); // [NEW CODE] // 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; } // Set up submissions in the ProcessWire page tree $np = new Page(); // create new page object $np->template = $templates->get("data"); // Set template for pages created from form submissions $np->parent = $pages->get("/test/"); // Set parent for pages created from form submissions // Send form submissions through ProcessWire sanitization and apply each to a template field for the new page $np->of(false); $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 for "contact_photo" foreach($files as $filename) { $pathname = $upload_path . $filename; $np->contact_photo->add($pathname); $np->message("Added file: $filename"); unlink($pathname); } // Run photo upload for "other_photos" [NEW CODE] foreach($other_files as $other_file) { $pathname = $upload_path . $other_file; $np->other_photos->add($pathname); $np->message("Added file: $other_file"); 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} ?> This is the error message I get: Parse Error: syntax error, unexpected '}' (line 73 of \site\templates\form.php) Line 73 is the curly bracket in this part at the end of the code: <?php return true; } Hopefully somebody can see better than me what is the problem here. This is the code of the form that is being processed by the code above: <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" /> <input type="file" name="other_photos[]" multiple /> <button type="submit">Submit</button> </form>
  9. Just came back from morning work and read your posts. Thanks for the replies I can make my self a better picture now where to go with this. Personally it would be better for me to use processwire as a backend as I would learn more from it. But in this case it looks I really have to go with android studio and use processwire as a backend for my next project.
  10. Bumping this thread: https://processwire.com/about/news/introducing-processwire-2.3/ Please put me in the right direction for Android applications. Thanks
  11. Could be during the zip, upload/migrate, unzip, that not all files made it correctly to the new server.
  12. https://processwire.com/talk/topic/8916-error-call-to-a-member-function-numchildren-on-a-non-object/
  13. Did you migrate a website ? Try to do the manual installation again, step by step.
  14. Also check if you are using a module that is not compatible with your current processwire version. Try to update them in Modules Manager
  15. No not in the wire/core/Pages.php because there only a jump or reference is made to the location where the error actually resides.
  16. The image example was only to find the right direction. Instead of an image it can also be a variable somewhere in your code that has no value assigned to it that processwire is looking for, etc. etc.
  17. Hi, I have to write a program in Android which basically contacts an online database, fetch updated data and shows it in a list on an android smartphone screen. So this made me thinking. Instead of learning all of Android what is needed to set this up, would it be possible to use Processwire as a backend that will communicate with the database and then only use some simple Android code for a front ? The advantage would be that I can stick to Processwire api that I already am learning. Maybe using the Processwire api could become a universal way of backend ? Native code on Android will usually be faster instead of using a backend, so where will I have to put Processwire as a backend in this case ?
  18. Each time when I have this error, processwire is looking for something and can not find it. Example: $image = $temp->images->get("name=logo.jpg"); Processwire is looking for logo.jpg but it is not there in the image field of the page or the image is there but under a different name, so Processwire can not find it and throws this error. I hope this example will set you in the right direction for your case.
  19. Came across this from contentessentials with an interesting sum up and migration: http://www.contentessentials.com.au/resources/essentially-cms/the-processwire-advantage/ http://www.contentessentials.com.au/resources/essentially-cms/migrating-a-web-application-from-drupal-to-processwire-a-case-study/
  20. Yes, can not agree more with that. Your post summed it up very well. I hope Processwire will never take the road of a washing powder to stay in the picture: "This Month we have added feature xyz and now you are able to do abc like never before" Let's never forget why so many people (e.g. from modx) migrated to Processwire: No typical, no shine, no show or fancy but raw power ! Sometimes I have my doubts if the core of Processwire will stay like this because if you look around in the world, the temptations of becoming part of the status quo, buzz or popularity, is immense. I hope Ryan and his team will never fall for it. The focus should not be the core but marketing Processwire.
  21. Processwire is chosen, wordpress is followed has nothing to do with defined in black and white in your world. Processwire is chosen by those after first having worked with other cms systems that did not satisfy. It is simply the reason why 99% hasn't heard of Processwire. Wordpress is followed because it is "so popular" and "so easy to use". Nothing new here.
  22. Processwire is chosen, wordpress is followed. This is your task to present to your clients "popular" (wordpress) or "effective" (processwire) How this works has been discussed already, you can find informative posts about this in the forum.
  23. https://processwire.com/blog/
  24. Google: processwire previous version https://processwire.com/talk/topic/4256-download-old-versions/ https://github.com/ryancramerdesign/ProcessWire/releases/
  25. Processwire is not like "all other major open source CMS", so are you sure about that ? To attract more people it certainly does not need cranking up it's core, but instead it needs more marketing.
×
×
  • Create New...