Jump to content

joe_ma

Members
  • Posts

    182
  • Joined

  • Last visited

Everything posted by joe_ma

  1. Hello I am trying to setup a reservation form for a restaurant. As I want to use bootstrap I like to build the form accordingly. That means the form is just HTML markup. So I tried to use Ryan’s simple-form as modified by Soma. I don’t get it to work properly. The template looks like this: <?php /** * basic-form.php - Example of a simple contact form in ProcessWire * */ include('./includes/header.inc'); ?> // here some HTML markup for leading Text etc. <?php $success_message = "<h2>Thank you, your message has been sent.</h2>"; $success = false; // we assume it and set to true if mail sent $error = false; // set and sanitize our form field values $form = array( 'datum' => $sanitizer->text($input->post->datum), 'ankunftszeit' => $sanitizer->text($input->post->ankunftszeit), 'anzahl_plaetze' => $sanitizer->text($input->post->anzahl_plaetze), 'name' => $sanitizer->text($input->post->name), 'adresse' => $sanitizer->text($input->post->adresse), 'plz' => $sanitizer->text($input->post->plz), 'ort' => $sanitizer->text($input->post->ort), 'email' => $sanitizer->email($input->post->email), 'tel' => $sanitizer->text($input->post->tel), 'extras' => $sanitizer->textarea($input->post->extras), ); print_r($form); // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($form as $key => $value) { if( strlen(trim($value)) == 0 ) { $error_message = "<h2 class='error'>Please check that you have completed all fields.</h2>"; $error = true; break; } } // if no errors, email the form results if(!$error) { $emailTo = 'me@me.com'; // of course I set the right email address ;-) if(empty($emailTo)) $emailTo = $users->get($config->superUserPageID)->email; $subject = "Contact Form"; $message = ''; foreach($form as $key => $value) $message .= "$key: $value\n"; if(mail($emailTo, $subject, $message, "From: $form[email]")){ $success = true; } } } ?> <?php if(!$success) : // : alternative version instead of {} ?> <form class="form-horizontal" action="./" method="post"> <fieldset> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="datum">Datum</label> <div class="col-md-5"> <input id="datum" name="datum" placeholder="Wann möchten Sie reservieren" class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="zeit">Zeit</label> <div class="col-md-5"> <input id="zeit" name="zeit" placeholder="Wann werden Sie eintreffen?" class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="anzahl_plaetze">Anzahl Plätze</label> <div class="col-md-5"> <input id="anzahl_plaetze" name="anzahl_plaetze" placeholder="Anzahl Personen" class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="name">Name</label> <div class="col-md-5"> <input id="name" name="name" placeholder="Vorname Nachname" class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="adresse">Adresse</label> <div class="col-md-5"> <input id="adresse" name="adresse" placeholder="Strasse, Nr." class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="plz">PLZ</label> <div class="col-md-5"> <input id="plz" name="plz" placeholder="Postleitzahl" class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="ort">Ort</label> <div class="col-md-5"> <input id="ort" name="ort" placeholder="Wohnort" class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="email">Email</label> <div class="col-md-5"> <input id="email" name="email" placeholder="mail@domain.ch" class="form-control input-md" required="" type="text"> </div> </div> <!-- Text input--> <div class="form-group"> <label class="col-md-5 control-label" for="tel">Tel.</label> <div class="col-md-5"> <input id="tel" name="tel" placeholder="031 999 99 99" class="form-control input-md" required="" type="text"> </div> </div> <!-- Textarea --> <div class="form-group"> <label class="col-md-5 control-label" for="extras">Spezielle Wünsche</label> <div class="col-md-5"> <textarea class="form-control" id="extras" name="extras"></textarea> </div> </div> <!-- Button --> <div class="form-group"> <label class="col-md-5 control-label" for="submit"></label> <div class="col-md-5"> <button id="submit" name="submit" class="btn btn-default">Abschicken</button> </div> </div> </fieldset> </form> <?php else: // if success ?> <?php echo $success_message; ?> <?php endif; // end if success ?> here some further HTML for sidebar etc. <?php include('./includes/footer.inc'); ?> I have set the correct email address to send the mail to. And the print_r($form); prints the correct input values after submission. I don't receive any mail and the success message is not being displayed but still the form. Second question: If I want to include the values also in the success message, what would be the way to do it? Something like: $success_message = "<h2>Thank you, your message has been sent.</h2>" . $message; Thanks for help.
  2. Thank you Pete for these explanations. I really appreciate help in php matters. Ah, but in the cheatsheet it does. And in fact if ($page->parentID == 1016) is working like expected.
  3. Small cause, great impact … Thank you onjegolders, that solved it.
  4. Obviously I still don't seem to get it right. I have just encountered another one I can't solve. I have a template, that I use for different kinds of news. The newsposts are in different folders. For news in one of the folders I want to display sort of a «Back»-button, news in the other folder don't need that button. So I have tried this: if ($page->parentID=1016) { echo '<p class="retour"><a class="btn btn-default" role="button" href="'.$pages->get("title=Anlässe")->url .'">Zurück zur Übersicht</a></p></div>; } But that has no effect at all. The «Back»-Button is displayed in all the newsposts of both folders, not only in the folder with the ID=1016. I have also tried if ($page->parentID="1016") { and if ($page->parent->title="Notti") { with the same results. Thank you for help.
  5. Thanks kongondo for the clarification.
  6. Thanks Pete I have tried your solution. But that throws an error: Or can't I use your solution in a function, but only directly in the template?
  7. Yessssssssssss!! Thank you very much 3fingers. You made my day.
  8. Oh, great! Didn't find these. Thanks kogondo!
  9. Hello I am playing around with the bootstrap profile. I'd like to use the carousel to display images, but only, if there are any. So I tried to write a function that I can use in the template. The function looks like this: function slider() { $albumimages = wire("page")->slider; $out =" "; if ($albumimages) { $out .= "<div id='myCarousel' class='carousel slide' data-ride='carousel'><div class='carousel-inner'>"; $i=0; foreach ($albumimages as $albumimage) { if ($i == 0) { $out .= "<div class='item active'>"; } else { $out .= "<div class='item'>"; } $i++; $out .= "<img class='img-responsive' src='{$albumimage->size(1170, 550)->url}'>"; $out .= "<div class='container'></div></div>"; } $out .="</div><a class='left carousel-control' href='#myCarousel' data-slide='prev'><span class='glyphicon glyphicon-chevron-left'></span></a><a class='right carousel-control' href='#myCarousel' data-slide='next'><span class='glyphicon glyphicon-chevron-right'></span></a> </div>"; echo $out; } else { $out =" "; echo $out; } } It works ok on pages that do have images. But on pages without images, it still is writing all the html. I don't find out, where I went wrong with the if-statement. Help is therefore very much needed and appreciated. Thanks
  10. Hello By default there are only 4 items on the page menu in the admin: edit, new, view, move. I should find it more convenient to have also hide, publish/unpublish and delete in this menubar. So you don't have to actually open the page to do one of this tasks. Is there a way to achieve that? Thanks
  11. Thanks Adrian Unfortunately that didn't change anything. In my test I have four events. One of them is in the past, three of them in the future. When I use Datum>time() all of them are displayed. With Datum<time() none of them is displayed.
  12. Hello I am playing around with this tutorial, trying to build some sort of event list. Thanks to Joss that works fairly well. I am stuck though, trying to display only events, that lie in the future. Old ones should not be displayed in the list (without deleting or unpublishing the corresponding page). All event-pages have a date field. So I tryed to achieve that like so: foreach($newsposts as $newspost){ $t = time(); if($t<$newspost->Datum) { $out .="<hr><div class='clearfix'>"; if($newspost->Artikelbild){ $out .="<a href='{$newspost->Artikelbild->url}' class=''>"; $out .="<img class='align_left' src='{$newspost->Artikelbild->url}'>"; $out .="</a>"; } $out .="<p>{$newspost->Datum}</p>"; $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; $out .= $newspost->body; $out .="</div>"; } } But that doesn’t display anything. As you can see, I am by no means a pro with php, so help is very much apreciated.
  13. Thanks very much diogo. Sometimes, solutions are very easy …
  14. Hello from a newbie I am playing around with PW for the first time, trying to build some kind of foto blog. So after I followed the steps in Joss’ tutorial for the gallery I modified and tweeked the files a bit to suit my wishes. Seems to work pretty well so far. Except … My albums are all in the folder "albums" (as suggested by Joss). So far I have three albums: Azoren, Berlin, Wien. On each page (and on the page, that gives an overview of the albums) I want to have a list of all the albums. So I took one of Joss’ functions and modified it like so: function albumList(){ // Get the list of albums $albums = wire("pages")->find("parent=/albums/, template=mat_gallery"); $out =" "; //Loop through the pages foreach($albums as $album){ $out .="<li><a href='{$album->url}'>{$album->title}</a></li>"; echo "<ul>$out</ul>"; } } What it produces is the following HTML: <ul> <li><a href='/processwire/albums/azoren/'>Azoren</a></li> </ul> <ul> <li><a href='/processwire/albums/azoren/'>Azoren</a></li> <li><a href='/processwire/albums/berlin/'>Berlin</a></li> </ul> <ul> <li><a href='/processwire/albums/azoren/'>Azoren</a></li> <li><a href='/processwire/albums/berlin/'>Berlin</a></li> <li><a href='/processwire/albums/wien/'>Wien</a></li> </ul> I.e. it keeps repeating the list in a strange way. I haven't the faintest as to where I went wrong. Help therefore apreciated very much. Thanks.
×
×
  • Create New...