-
Posts
733 -
Joined
-
Last visited
-
Days Won
9
Everything posted by SamC
-
I remember a while back another member had something like this. Not sure it's related but worth a shot.
-
I had to modify the code a little because HTML formatting wasn't happening when I received the emails. Mine is as follows: <?php require(dirname(__FILE__) . "/../../vendor/vlucas/valitron/src/Valitron/Validator.php"); require(dirname(__FILE__) . '/../../vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php'); $v = new \Valitron\Validator(array( 'name' => $sanitizer->text($input->post->name), 'email' => $sanitizer->email($input->post->email), 'message' => $sanitizer->text($input->post->message), ) ); $v->rule('required', ['name', 'email', 'message']); $v->rule('lengthMin', 'name', 3); $v->rule('email', 'email'); $googleSiteKey = 'xxxxxxxxxxx'; $googleSecretKey = 'xxxxxxxxxxx'; $contactFormRecipient = 'my_email'; $contactPageID = '1022'; if ($input->post->name) { if ($v->validate()) { $reCaptcha = new \ReCaptcha\ReCaptcha($googleSecretKey); $resp = $reCaptcha->verify($input->post->{'g-recaptcha-response'}, $_SERVER["REMOTE_ADDR"]); if ($resp->isSuccess()) { $name = $input->post->name; $email = $input->post->email; $message = $input->post->message; $message = " <html> <body> <p><b>From:</b></p> <p>{$name}</p> <p><b>Email:</b></p> <p>{$email}</p> <p><b>Message:</b></p> <p>{$message}</p> </body> </html>"; $mail = wireMail(); $mail->to($contactFormRecipient) ->from($email) ->subject('Contact form submission') ->bodyHTML($message) ->send(); $session->flashMessage = '<h2>Thanks for the message. I will get in touch with you shortly.</h2>'; $session->sent = true; $session->redirect($pages->get($contactPageID)->url); } else { $session->flashMessage = 'Error while validating you are not a robot!'; } } } ?> <div class="body-row"> <div class="wrapper"> <?php if($session->flashMessage):?> <div class="alert <?=!$session->sent && (!$v->validate() || !$resp->isSuccess()) ? 'alert-danger' : 'alert-success'?>" role="alert"> <?php echo $session->flashMessage;?> </div> <?php endif;?> <form id="contact-form" method="post"> <div class="<?=$v->errors('name') ? 'has-error' : ''?>"> <label for="name">Name</label> <input class="form-control" name="name" id="name" type="text" value="<?=$sanitizer->text($input->post->name)?>"> </div> <div class="<?=$v->errors('email') ? 'has-error' : ''?>"> <label for="email">Email</label> <input class="form-control" name="email" id="email" type="text" value="<?=$sanitizer->text($input->post->email)?>"> </div> <div class="<?=$v->errors('message') ? 'has-error' : ''?>"> <label for="message">Message</label> <textarea class="form-control" name="message" id="message"><?=$sanitizer->text($input->post->message)?></textarea> </div> <div> <!-- Google Recaptcha code START --> <div class="g-recaptcha" data-sitekey="<?=$googleSiteKey?>"></div> <script type="text/javascript" src="https://www.google.com/recaptcha/api.js"> </script> <!-- Google Recaptcha code END --> </div> <div class="centered"> <button type="submit">SEND MESSAGE</button> </div> </form> </div> </div> <?php $session->remove('flashMessage'); $session->sent = false; ?> Works now with proper formatting.
- 76 replies
-
- 2
-
Getting the same thing here, I followed this guide: ...everything works but I receive plain text emails with HTML tags in them. I'll try what you did see if I have some success. Thanks. --EDIT-- Got it working now:
-
What I did in the end was create a second DB on my server appended '_dev'. Now I can just get on with building some stuff instead of wasting time
-
Thanks for the suggestions. I'll put this on the back burner, really need to stick at javascript for awhile first, although I'm finding it pretty tedious. Don't know what it is with me and javascript, been trying to learn it off and on since about 2004 to no avail, always quit and go mess about with CSS and design instead. I guess I don't have anything to actually use it for right now other than adding classes here and there. Then I was thinking last week about an ajax search which users could find pages on my site without navigating around by typing in questions, like "How much..." would pop up my pricing page etc, That would need javascript! And I'd have a goal. Then I saw this: Copying and pasting wont get me anywhere, but this will really address the 'where to start' problem us wannabe developers have. Reading JS books and watching videos is all well and good but this gives me something to learn as I go along, makes all the difference to me. Went a bit off topic there, but hey.
-
Can ProcessWire do this? (User Management, Profiles, Search)
SamC replied to Kai's topic in Getting Started
@Robin S awesome, I'll check it out thanks.- 23 replies
-
- search
- user-management
-
(and 1 more)
Tagged with:
-
Can ProcessWire do this? (User Management, Profiles, Search)
SamC replied to Kai's topic in Getting Started
Ok, I see now, so people who register on a site never get to see the admin area. This part was confusing me, I thought people always went to the page tree after login. Guess I've still got a lot to learn.- 23 replies
-
- search
- user-management
-
(and 1 more)
Tagged with:
-
I've been doing local development for quite some time, so setting up up initially isn't a problem. What I could do with is some advice. What I do at the moment is not ideal but it works (although not what I would call 'robust'): 1) PC - XAMPP (apache/php/mysql) 2) Macbook - MAMP (apache/php/mysql) 3) Dropbox on both - /dev/dev.mysite.com/PW-installation 4) Live hosting server with database 5) I connect to the files from dropbox, and the live database from both machines (in config.php, my hosting allows remote connection) and also test on mobile (once the files are uploaded to the live server) 6) Both machines are not always on, so connecting to a server on the other one isn't really an option 7) My virtualhosts and hosts are set up identically on each machine so the local URLs are the same 8) Both files and database are backed up on the server daily so I can rollback if something goes pear shaped There is a good chance of human error in this setup and I have to be careful. I frequently hop between macbook (sitting in bed) and PC (downstairs). Now this setup allows me to go between computers no problem and totally works. However, I don't really want to keep messing with the live database or store files in dropbox. I'm only doing this because I haven't got into git yet, never seems to be enough time. My initial discussions about using dropbox were here: The live database bit concerns me, if something goes wrong, the whole lot is messed up, been lucky so far but that runs out eventually! I suppose I could create a 2nd database on the live sever DBNAME_dev and use that but interested to see how other people handle this type of situation. I really need a decent solution before taking on paid work because this whole setup worries me and I think I'd be doing a dis-service by not having a solid foundation to begin with. I'm willing to get my hands dirty but I've never worked in an environment where tools for this sort of stuff are used, and how they do it etc. I'm actually heading over to https://laracasts.com/series/git-me-some-version-control now to start the ball rolling but any advice is greatly appreciated, thanks.
-
Can ProcessWire do this? (User Management, Profiles, Search)
SamC replied to Kai's topic in Getting Started
User management 1) each user gets a profile page 2) each user can define his own custom URL for his profile page Sorry to hijack, but this is something I'm interested in but can't see how this works in PW. When they log in, they go to a profile page rather than the admin tree page? How is it done? Whenever I create a new user in testing, when I log in with their, the admin page is always the destination.- 23 replies
-
- search
- user-management
-
(and 1 more)
Tagged with:
-
@Robin S thanks for the advice. I design sites from scratch with my own small sass boilerplate for typography etc, including the awesome @include-media for breakpoints, best solution I've seen. My CSS skills outweigh my JS ones but I'm working hard on JS at the moment to catch up a bit (although the syntax bothers me somewhat). My charity work is the mental health/learning disabilities sector and it is a field I'd like to stay close to. I feel they make an actual difference to people, rather than the 'design studio look at our new ad for pepsi' stuff. Worth millions but all it's good for is giving people bad teeth. My PHP skills are ok (as long as I have the manual close...) but this is why I like the PW API so much, grabbing stuff out the database just couldn't be simpler. Anyway, I'm rambling. I just love making websites basically! Have done for over a decade, it never gets old for me, my enthusiasm probably outweighs all my skills combined
-
@Cole that's really useful, thanks for the tip. I'll try that out, one less difference between the local & live .htaccess to worry about.
-
Totally works, you're a gent. Thanks
-
I've got a page type field which I use to add a custom content block (page) into my page like so (which just has a title and body field): // main.php <?php if ($page->insertContentBlock) { $block = $page->insertContentBlock; } else { $block = $pages->get("/content-blocks/my-services/"); } echo $block->body; ?> I'm after a way of hiding the 'Contact me' block because that is always in the footer and never needs to be added to any other area of the page (or it'll be on their twice). You can see in the first screenshot from the tree hierarchy that the page is hidden... ...but still shows up in this menu when editing a page to add a block... If I unpublish it, then it does not show in the menu, but this seems like a weird solution. To a client, they would just see 'Contact me', greyed out with a line through it, wouldn't make a great deal of sense. Is there something I can put in the 'custom selector to find selectable pages' that will honour the hidden status of this 'Contact me' page? I hope this makes sense. Any advice is appreciated, thanks.
-
I don't understand this part. I tried doing this locally ( I use dev.mysite.com like you) with the www enabled and it doesn't work. You end up being redirected to www.dev.mysite.com. I have to leave the www disabled locally, and have it enabled on the live server, same with the https option. Does your local site work without the www?
-
@ridgedale I don't use the delayed output method but looking at the page source on your site, looks like your templates are being automatically included like this to produce a final page output at yoursite.com/news/: 1) _init.php 2) news-index.php 3) _main.php You're getting this on your page: <!-- THIS LINE IS OUTPUTTING FROM NEWS-INDEX.PHP BECAUSE YOU GOT ECHO COMMANDS IN THERE --> <ul></ul><h5>Showing 0 - 0 of 0 Article(s) | Page 1 of 0</h5> <!-- THEN _MAIN.PHP LOADS AFTER THE PREVIOUS TEMPLATE --> <!DOCTYPE html> <html lang="en"> <head> Your news-index.php is supposed to populate placeholders (i.e. not echo out anything), then the _main.php actually outputs the page using the predefined values. So maybe you need to do something like: // news-index.php // define the placemarker headline $placeholderHeadline = "Showing $start - $end of $total Article(s) | Page $num of $lastNum"; // main.php - this outputs the final page // put this line where you want it to show on the page <h5><?php echo $placeholderHeadline; ?></h5> https://processwire.com/docs/tutorials/how-to-structure-your-template-files/page4 Another approach is what I do, which I find easier and more obvious what's going on: 1) Go to config.php and modify it so that the _main.php file IS NOT appended (this is what's happening to you). /** * Prepend template file * * PHP file in /site/templates/ that will be loaded before each page's template file. * Example: _init.php * * @var string * */ $config->prependTemplateFile = '_init.php'; /** * Append template file * * PHP file in /site/templates/ that will be loaded after each page's template file. * Example: _main.php * * @var string * */ // I COMMENT OUT THE FOLLOWING LINE // $config->appendTemplateFile = 'main.php'; 2) Create file main.php (this is used to serve ALL of my pages 3) Create template, services-index.php, create file services-index.php 4) Go to template > files tab > alternate template filename - type 'main' (I do this for EVERY template that needs its own page) 5) Put the code in the files // main.php <!DOCTYPE html> <html lang='en' class='no-js'> <head> </head> <body> <!-- my header is in another file at /templates/includes/header.inc --> <?php include('./includes/header.inc'); ?> <!-- start main content --> <?php include($page->template->name); ?> <!-- my footer is in another file at /templates/includes/footer.inc --> <?php include('./includes/footer.inc'); ?> </body> </html> // services-index.php <p>I'm loaded now through main when you go to mysite.com/services/ how awesome is that!</p> I figure that the only part that generally changes on page is the middle section between header and footer. And if I need something to change in the header, I just include a header file like I did with the footer. Then I can use logic in that file to output different things depending on what's needed. Hope this makes sense and gives you some ideas of the different approaches available.
-
-
The "mess and a nightmare" bit refers to this list expanding and becoming more difficult to manage. But it seems I shouldn't be too concerned about this I don't earn an income from making websites, I'm a charity worker 3/4 days a week so web stuff has to get squeezed in evenings/weekends and 1 or 2 days a week. I've been doing it since about 2004 off and on, made a go of it self-employed in 2012-2015, made some £££ with Drupal (websites plus consultancy on responsive design) but couldn't continue because of working full time, balancing family life and doing a computer science diploma at the same time drained me. Just not enough hours in the week! I have a part time job now (so more time to give self employment a decent shot) so this is another reason why workflow has to be fast (and why I have enjoyed PW so much), although it hasn't 'saved' me any money so far because I gotta make some first. I'm striving towards doing this full time, although 'custom websites' seems quite a difficult niche to carve out because if all the templates available online. Still debating whether to offer 'all bespoke' or have a cheapo option where I plug in a template of their choice. Of course, PW makes this easy and I did exactly this for my stepson, grabbed a static template, converted to PW, job done. I've made three PW sites so far, my own (work in progress) and two freebies for local charities, but I've already heard the dreaded "why not use a free wordpress template, then I can install plugins as required". The influence is strong with WP. <?php define( 'WP_USE_THEMES', false ); get_header(); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <p>Bang head repeatedly against the wall</p> <?php endwhile; else : ?> <p><?php _e( 'Sorry, better get back to the codex.' ); ?></p> <?php endif; ?> Anyway, thanks for the advice people, I'm also off to the store to buy profields. --EDIT-- Installed and ready to go, pretty excited
-
How to: DIfferent links in one DIV - HTML CSS question
SamC replied to kuba2's topic in General Support
Ha, great vid! -
Think I got this right. If I haven't, then I accept all mockery if 1037 !== 1037 || 1037 !== 1038 FALSE || TRUE - runs if 1038 !== 1037 || 1038 !== 1038 TRUE || FALSE - runs if 100 !== 1037 || 100 !== 1038 TRUE || TRUE - runs //...seems this || block will ALWAYS run... // ...what about with &&... if 1037 !== 1037 && 1037 !== 1038 FALSE && TRUE - doesnt run if 1038 !== 1037 && 1038 !== 1038 TRUE && FALSE - doesnt run if 100 !== 1037 && 100 !== 1038 TRUE && TRUE - runs
-
Hi everyone, I've been going back and forth trying to decide whether or not to buy the profields. I find myself being dictated by the fields which then ends up in the overall design on the page on a website, if that makes any sense. I want more freedom, to be able to pen out a design, and know I've got maximum flexibility and being able to re-use fields as much as possible (I'll go into this). The user experience (i.e. client editing pages) is paramount. It's no good if I'm the only one who understands it. For example, I want a page: ---LOGO - MENU--- Main image (image field, allow 1 only) Title (text field) Short summary/or something (text area) Body text (text area ckeditor) ---FULL WIDTH BAR--- Title (text field) Body text (text area ckeditor) ---END FULL WIDTH BAR--- ---FULL WIDTH BAR--- Title (text field) Images (a gallery or something - image field, multiple array, unlimited) Body text (text area ckeditor) ---END FULL WIDTH BAR--- ---FULL WIDTH BAR--- Body (text area ckeditor) Quote (text area) ---END FULL WIDTH BAR--- So it seems it doesn't take long to start requiring fields that don't quite cover each other (and need multiple titles for example). So I start doing things like: title - text field summaryTitle - text field galleryTitle - text field postBodyTitle - text field body - text area (ckeditor) postBody - text area (ckeditor) galleryBody - text area (ckeditor) It's a mess, and a nightmare. Will profields allow me to reuse fields much more efficiently than the above? Or is there simply a better way to do this using existing fields? i.e. how do I handle having more than one title on the page, or multiple body text areas? I came from Drupal, then Craft CMS, and the matrix field in craft was the business. This was exactly the type of scenario that it was made for. Seems the profields repeater matrix may solve a bunch of my problems in one fell swoop but after a few insights first as it's £100 and I'm on a very tight budget. I 'can' buy it, but need some good reasons to do that first as I don't have the luxury right now of being to buy it just to experiment. Any extra information (read: persuasion) is appreciated. Thanks.
-
Did you build this whole thing with processwire or is it an add-on from somewhere? I like the idea of this. Thanks.
-
I've used bourbon/neat for about the last couple of years, really simple to use for layouts: http://neat.bourbon.io/ Works great for me so far. I do exactly the same thing on my Windows PC using scoop http://scoop.sh/ (instead of homebrew https://brew.sh/ on the OSX laptop) to set up node.js/gulp (to compile the scss). Not sure this answers your question, but this is how I develop responsive sites.
-
@giannisok thanks for sharing this, is awesome for a simple form where I don't need to save the user data anywhere! Got it all working with recaptcha/validation, however, when I receive the email, it's still as plain text: // received email <html> <head> <meta http-equiv="Content-Type: text/html" content="text/html; charset=utf-8" /> <title>Contact Form | Sam</title> </head> <body> <p>test message</p> </body> </html> Any ideas why this is? The content type is set so I thought it would show as formatted html. Thanks for any info.
- 76 replies
-
- 1
-
Just as a follow up, this is what I did to get content blocks (each a page with no template) into a set area (in my case the footer) of my site. 1) Created two templates, content-block-index (advanced tab = icon cubes) and content-block (advanced tab = icon cube) 2) Added 'title' (type = text) and 'body' (type = textarea) fields to content-block template 3) Created a page (called Content blocks) using the content-block-index template 4) Created a few subpages of this using the content-block template plus populated title/body fields (title only used to label in admin, not output anywhere) 5) Created a field 'insertContentBlock' (type = Page), details = single page or boolean false when none selected, input = parent of selectable pages, chose 'Content blocks' page 6) Added insertContentBlock field to any pages where I want to choose a custom block in the footer 7) Edit a page which includes the field created in (5), choose one of the content-block pages, save To output, I just put this in the footer (which itself is an include from main.php) // ./includes/footer.inc // if page is not 404 page <?php if ($page->id !== 27): ?> <div class='row'> <div class='column-l colour-bg'> <?php if ($page->insertContentBlock) { $block = $page->insertContentBlock; } // if no selection, default block else { $block = $pages->get("/content-blocks/my-services/"); } echo $block->body; ?> </div> <div class='column-r'> <?php // this block doesnt change $block = $pages->get('/content-blocks/contact-me/'); echo $block->body; ?> </div> </div> <?php endif; ?> Maybe not the most elegant but it suits my requirements and gave me a good idea what the Page field does. Anyway, might help someone.
- 1 reply
-
- 1