Jump to content

kyle

Members
  • Posts

    32
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by kyle

  1. @konondo thanks for the direction; however I had gotten that far. This issue is when you try to foreach through $ad_images the output doesn't list a file name. foreach: foreach($ad_images as $image): var_dump($image); endforeach; output: string(1) " " string(0) "" string(0) "" string(0) "" int(0) string(0) "" string(0) "" bool(false) string(16) "JPG JPEG GIF PNG" int(0) int(2097152) int(0) int(0) int(0) int(1) string(69) ".../site/assets/files/1024/" string(40) "InputfieldFile InputfieldImage ui-widget" string(11) "Description" string(4) "Tags" bool(false) string(0) "" string(0) "" int(100) I looked around more, and I have seen threads of people being able to upload files using WireUpload and by coding their own forms, but I haven't been able to find any examples of people accomplishing this with the API form method.
  2. @ryan What if it is a photo upload? I have seen some discussion on the site about uploading photos from the front end, but I haven't been able to find any that uses the API. Right now I create the image field: //images $field_furn = $modules->get("InputfieldImage"); $field_furn->label = " "; $field_furn->name = "ad_images"; $field_furn->id = "ad_images"; $field_furn->maxFilesize = 2*1024*1024; $form_furn->append($field_furn); Create a field upon submission: $ad_images = $form_furn->get("ad_images"); And upon a successful submission, I create a new page. Images are uploaded, but how would I attach the images to a newly created page?
  3. I tried to create a page via the API without a name and it displayed an error saying the name had to be set. This is my solution based off of the the code Wanze posted. /* * Clean URL */ function clean_string($string) { return trim(preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-'); } /* * Check for duplicate name */ function check_name ($title, $path) { $parent_page = wire("pages")->get($path); $n = 0; $pageName = strtolower(clean_string($title)); do { $name = $pageName . ($n ? "-$n" : ''); $child = $parent_page->child("name=$name"); // see if another page already has the same name $n++; } while($child->id); return $name; }
  4. What is the best way to create a file input field to allow a visitor to submit a document that gets emailed on a successful form submission? This is my code right now, but after the submission (successful or not) it reads no file chosen. //create upload field $field = $modules->get("InputfieldFile"); $field->label = " "; $field->description = "Upload your plan. File type must be doc, docx, or pdf."; $field->required = 1; $field->id = "file"; $field->name = "file"; $field->maxFiles = 1; $field->maxFileSize = 1024 * 10; $field->destinationPath = "/tmp/"; $field->extension = "pdf doc docx"; $form->append($field); The tmp folder is located in the root of the site (where the site and wire folders are), and I thought it may have been a permissions issue, but it still reads no file uploaded even after I did chmod 777.
  5. Thanks for this post, it has been really helpful! Is there anyway to use HTML in the $field->description? Also, I think that I looked through all the posts and couldn't find anything, is there a way to choose a default selected option for InputfieldSelect?
  6. @adrian Thanks so much for the help. This was a preliminary question for my upcoming project, and I will let you know if I have any issues! Thanks for the welcome, I was lucky enough to find out about Processwire and it has quickly become my go-to CMS. @renobird Thank you!
  7. I took a look through the API but couldn't seem to find a way to get the pages created by a user. I was hoping that there would be some sort of array that tracks the pages that a user created and would be accessible with something like $user->pagesCreated(). If there isn't anything link this in processwire, how difficult would it be to create?
×
×
  • Create New...