Jump to content

ryanC

Members
  • Posts

    97
  • Joined

  • Last visited

Everything posted by ryanC

  1. Not getting anywhere yet, and these seem pretty thorough. When I was testing this out of my regular htdocs folder, I had to add the "-f" before my email address to get the email, something to do with validation. I have added that 'f' to your two examples just to see what would happen, no email yet. Is it possible that ProcessWire being installed locally (and not installed on an actual web server) have anything to do with it? ...also I have it set up like this: form itself is on one page which is based on my main template, and the form results page is based on an entirely different template. ... this edit is a few hours later... from one of the threads above it mentions that the Wire Mail SMPT settings must be your email account and not your php ini settings. I entered my gmail SMTP hostname etc and it now says "SMTP settings appear to work correctly". I thought that would have been the culprit but still no email.
  2. Thanks Sam and szabesz--I will test these out!
  3. Ok... I am still not able to even start understanding this. I have read the links.... I can't get it. I am trying. Clearly knowing PHP is the answer, but I am not a programmer. I have created a basic form page: <form id="simpleForm1" action="http://localhost:8888/sitename/form-response-1" method="post" target="_blank"> <label for="name">Name:</label> <input type="text" name="name" id="name"> <label for="email">Email:</label> <input type="email" name="email" id="email"><br /><br /> <label for="comments">Comments:</label> <textarea name="comments" id="comments"></textarea> <div class="submission-test"> <input type="submit" name="submit" value="Submit"> </div> </form> And here is the post page that the form goes to (I'll call it Code A) <?php $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL); if($email) { $headers .="\r\nReply-To: $email"; } $headers = "From: myemail@xyz.com\r\n"; $headers .= 'Content-Type: text/plain; charset=utf-8'; if (isset($_POST['submit'])) { $to = 'myemail@xyz.com'; $subject = 'Feedback from my site'; $message = 'Name: ' . $_POST['name'] . "\r\n\r\n"; $message .='Email: ' . $_POST['email'] . "\r\n\r\n"; $message .='Comments: ' .$_POST['comments']; $success = mail($to, $subject, $message, $headers, '-fmyemail@xyz.com'); } ?> This is the new code I'm trying to work my head around (I'll call it Code B). <?php $mail = wireMail(); ?> <?php $mail = wireMail(); $mail->to('myemail@xyz.com')->from('myemail@xyz.com'); // all calls can be chained $mail->subject('Mail Subject'); $mail->body('Mail Body'); $mail->bodyHTML('<html><body><h1>Mail Body</h1></body></html>'); $mail->submit(); ?> Does this new code replace the original code from Code A? Or maybe another way to ask... could this new wireMail code be worked into my HTML above? Alternately, I've seen people use something called Swiftmailer... would that be easier for me to implement? Maybe another third party service? I appreciate the help... I know these seem like really basic questions but I feel like someone in an algebra class who has the math skills of a third grader. You guys probably feel like I do when I try show my parents how to use their remote control.
  4. Thanks for explaining that szabesz, much of that makes sense as it builds on what I've been doing with non-form pages in processwire. I'm sure part of it is this is my first tackling of HTML forms in general, so I'm adding an extra level of abstraction to something I don't fully understand in the first place. I understand that $variables point to something else, I get the concept of classes as that is similar to CSS, I see how wireMail and WireMail have different purposes, so I guess I'm half-way there. I'm going to start with a new basic test form and see if I can get some kind of functionality going.
  5. Do you know where I might do this? I've been looking at these links, I am way over my head here. I'm good with HTML and CSS, and am learning the PHP stuff I can as I develop the site, but this is way beyond me right now. The form I'm making is very customized, with images, it's not just a contact form. I can't rebuild it from scratch--It does everything I need, I just need Processwire to treat email the way my local machine is treating email. As far as I know the code above is where the "chain" ends, where does the object "$mail" fit into the bigger picture? The php "mail" on the last line... $success = mail($to, $subject, $message, $headers, '-fmyemail@xyz.com'); ....isn't that the "mail" that "$mail = wireMail();" is pointing to? I've already tried changing it to: $success = $mail($to, $subject, $message, $headers, '-fmyemail@xyz.com'); But that was just a guess.
  6. Thanks szabesz! I'm sure I will be back here with more questions after going over these links.
  7. Hi, I am testing my Processwire site locally through MAMP. I have created a form (outside of processwire) and managed to have the form send an email to myself. Now that I am trying to integrate that form into Processwire, the email is no longer being sent. I have done some searches, and see people are using wireMail, but I am not sure if that is what I need at this stage. The working code for the form I have is this: $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL); if($email) { $headers .="\r\nReply-To: $email"; } $headers = "From: myemail@xyz.com\r\n"; $headers .= 'Content-Type: text/plain; charset=utf-8'; if (isset($_POST['submit'])) { $to = 'myemail@xyz.com'; $subject = 'Feedback from my site'; $message = 'Name: ' . $_POST['name'] . "\r\n\r\n"; $message .='Email: ' . $_POST['email'] . "\r\n\r\n"; $message .='Comments: ' .$_POST['comments']. "\r\n\r\n"; //custom // $message .='largestyle: ' .$_POST['largestyle']. "\r\n\r\n"; $message .='large: ' .$_POST['large']. "\r\n\r\n"; $message .='medium: ' .$_POST['medium']. "\r\n\r\n"; $message .='small: ' .$_POST['small']. "\r\n\r\n"; $success = mail($to, $subject, $message, $headers, '-fmyemail@xyz.com'); } So far, all I know is that adding the letter "f" to my email (last line of code) is the thing that's supposed to make the email work. If I were to add wireMail to this, where exactly would it go? I added this: <?php $mail = wireMail(); ?> to the top of the document but that didn't do anything. Any ideas? Thanks!
  8. Awesome, thanks.
  9. It works! Thanks again, now I can see all the things I can do with Hanna code.
  10. I think I have set that way, I'm attaching a screenshot of all the parts involved (other than the include folder itself).
  11. Hi, I am trying this Hannah example out, I think I am missing a step. I created a new php Hannah code called test that contains this: <?php $file = "{$config->paths->templates}includes/{$file}.php"; if (file_exists($file)) include $file; made a new include file at templates/includes with: <?php namespace ProcessWire; // test.php echo 'hello'; ?> <p>regular html</p> and in my page content field I have [[include file=test]] but the page output just gives me "[[include file=test]]"
  12. Thanks abdus, I will test that out!
  13. Ok thanks, maybe I'll give it another try.
  14. Thanks abdus, does this apply even if the field isn't a regular textarea? I should have added that I am using the AceExtended module. I have a lot of HTML content in there already, which is working fine, like : <section> <div class="xyz"> <img src="images/photo.jpg" /> </div> </section> I wonder if using a javascript text would be a work around. I did look into that Hannah page, I'd like to use it but it's a little beyond my skill level.
  15. Hi, I have php includes in my template file that are working fine....however I need to have some additional includes within a text area field, where I enter my HTML content. For example, this code at the top of my template file: <?php $myPath = $config->urls->templates;?> Allows me to have something like this on every page: <?php include("includes/footer.inc.php"); ?> So far so good, but I have a text area field named page_content, where I would like to manually enter additional includes. If I enter this in that text area field, I get a photo: <img src="images/photo.jpg" /> But if I enter this in that same field, nothing happens at all: <?php include("includes/phone.inc.php"); ?> Any thoughts? I have reviewed this thread https://processwire.com/api/ref/files/include/ but I don't think it gets at what I'm looking for. Thanks!
  16. Thanks for the tips, szabesz! Didn't see this post when you first made it.
  17. I think I solved it. Right when I think I won't be able to, I found this: echo "<img src='{$product_repeat->images->first->url}'>"; So my code is now: <?php foreach($page->product_repeat as $product_repeat) { echo "<div class='repeatItem'>"; echo "<h2>{$product_repeat->title}</h2>"; echo "<p>{$product_repeat->body}</p> "; echo "<img src='{$product_repeat->images->first->url}'>"; /*this shouldn't have to move*/ echo "</div>"; } ?> totally removed the "for each" stuff.
  18. Hi, this is a followup to my last thread. I have tried to figure this out on my own by searching the forum and researching how the image field works, but I am having no luck so far. My page is meant to function as a simple image gallery, with one unique image per instance of repeater. I am using the default images field, with a maximum of 0, making it an array. I think my issue is probably related to it being an array. Right now I have two instances of the repeater on my Processwire page. Item 1 (cherry photo) and Item 2 (orange photo). I have created div in so I can style my repeaters with CSS. This is the code I have in my template: <?php foreach($page->product_repeat as $product_repeat) { echo "<div class='repeatItem'>"; echo "<h2>{$product_repeat->title}</h2>"; echo "<p>{$product_repeat->body}</p> "; /*images go below*/ foreach($page->product_repeat as $image) { foreach($image->images as $image) { echo "<img src='$image->url'>"; } } echo "</div>"; } ?> Attached is a screenshot of the final result: All good except the photos are being duplicated. Item 1 only has the cherry photo in its image field. Item 2 only has the orange photo in its image field. The confusing part for me is, the titles and text aren’t being duplicated here. Only the photos. I figured this has something to do with the images field itself being an array … and I know I am supposed to add something like this to my code: ->first() But wherever I put it, either it does nothing, or it makes the images disappear completely. I tried to solve this entire thing by creating a new image field with a maximum set to 1…. but when I do that no image shows up at all. The only way I can get the images to show up is if it’s set to 0, which duplicates the images. Any help on this would be greatly appreciated. How would you add the "first" part of the image code to my code? Thanks!
  19. Makes sense, I don't need to overcomplicate things for myself. I went back and created a new image field called "myphoto" and it works. I won't use multiple named image fields unless necessary, but at least now I understand how it works!
  20. Ok, that is where I was getting confused. I thought there was only one standard image field available, but I can create many image fields with their own names. Thanks again.
  21. Perfect! Thanks guys! This now works: <?php foreach($page->myrepeat as $images) { foreach($images->images as $image) { echo "<img src='$image->url'>"; } } ?> So the label I created for "myphoto" doesn't actually do anything? Meaning, the "images" field is always going to be called images, and you can't/shouldn't rename it?
  22. I hope not, I can get images to show up on the page that are not in a repeater. This code for a different field is on the same template and it's working on the same page I'm trying to use the repeater on. <?php foreach($page->result_pic as $image) { echo "<img src='$image->url'>"; }?>
  23. Testing on a local machine, I took some screenshots of what I have though, the repeater field itself, the field being used on a page, and my image settings:
  24. Thanks PWaddict, I'm not sure where to start with that. I know these are basic questions but I do not know php well enough to make sense of a lot of this stuff.
×
×
  • Create New...