Everything posted by Red11
-
Vimeo Options and API
Hi there, I am trying to remove controls from vimeo videos. Adding &controls=0 no longer seems to work. It seems this is achieved now by accessing the videos via api. I have no experiene with api's. I understand how to create an app in vimeo and generate the token, and add the following code to display the video's, but there's a chunk in the middle - I assume where the site retrieves the data from the api - that I am missing. <div id="made-in-ny"></div> <script src="https://player.vimeo.com/api/player.js"></script> <script> const options = { id: 59777392, width: 640, loop: true }; const player = new Vimeo.Player('made-in-ny', options); Can you help?
-
htaccess and directly accessing pages
Hi all, I have 2 pieces to my htaccess that seem to have conflicting interests. The first block is what I have added as the site is built with Vue and the tutorial suggested this. The second is from my old site and forwards requests without 'www' to the address with 'www'. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] RewriteCond %{HTTP_HOST} ^address.co.uk [NC] RewriteRule ^(.*)$ http://www.address.co.uk/$1 [L,R=301,NC] </IfModule> The non 'www' url forwards correctly when on the homepage, but if someone directly accesses a sub page without adding 'www' it simply just stalls on loading. Is this easy to overcome? At worst I will the second part for the time being, but would be great to know if there is a simple solution to this. Thanks
-
External Image Hosting
Thanks for the helpful advice. As the site in question is fairly small with a UK-only audience I will definitely be keeping them on the site...
-
External Image Hosting
Hi there, Been hearing a bit about using 3rd party image hosting websites and the benefits. I am interested in trialling it on a website, because of its apparent speed efficiency being able to supply viewer with webp images if they can support it, and at the correct size. But have a couple of questions: - Is it benificial on small websites or just larger ones? (was going to try it on a small static site built with Vue) - Is it a lot of work to configure? I was thinking of going with https://imagekit.io/, but if the benefits are only slight for the work involved, will leave this for a larger project. Thanks
-
Password Protect Pages Using HTACCESS
Thanks NOCK I will look into this.
-
Password Protect Pages Using HTACCESS
that is true the information is not sensitive in any way, more just a case of being able to block the average user. As the rest of the site does not use databases, I am wondering if there are any alternative methods to DB or cookies?
-
Password Protect Pages Using HTACCESS
Hi there, I have built a site sith Vue.js and wanted to protect some pages with a password. From what I have seen, using .htaccess is a good method. But... Is there a (relatively) secure way when a user has entered the password they don't need to again for the rest of the visit? I was thinking storing a cookie or something, but is this easily hackable? Thanks
-
Basic Array Filtering
ok, thanks for asking the question, because it highlighted to me that category was not even available from where I thought it was... Going to have to rethink. Thanks
-
Basic Array Filtering
I am new to PHP, and have been dropped in to a job a little out of my depth to try and work something out. I have a list of items and quantities from different departments. I am trying to count the number of items from a certain group of departments in that list, and assign that number to a variable. eg: item 1 has qty of 1 and is from category_id 2 item 2 has qty of 1 and is from category_id 5 item 3 has qty of 1 and is from category_id 3 How would I get that to work from the following? $group1 = function () { return array_sum( return array_map( function ($item) { return count(array_intersect($item->product->category_id, [2, 3])) ? $item->qty : 0; }, ) ), }; Thanks
-
SCSS @each Syntax Error
Ah I think my error is not coming from this bit of code... Thanks for the resource link though that will be helpful for future tests
-
SCSS @each Syntax Error
I am aiming for the following: .white { color: #fff !important; } .white-bg { background-color: #fff !important; } .white-border { border-color: #fff !important; } .purple { color: #20123a !important; } .purple-bg { background-color: #20123a !important; } .purple-border { border-color: #20123a !important; } etc.. Thanks
-
SCSS @each Syntax Error
Hi all, I am fairly to new SCSS, and trying to create 3 classes each for a set of 5 name and value pairs. It works, but the outputted css shows each class 5 times! So something is being wrongly referenced here: $colours: ( white: #fff, purple: #20123a, green: #39C271, duskblue: #000473, skyblue: #41B8BC ); @each $name, $value in $colours { .#{$name} { color: $value !important; } .#{$name}-bg { background-color: $value !important; } .#{$name}-border { border-color: $value !important; } } Let me know what I am doing wrong here! Thanks
-
Webforms and File Upload Handling With Ajax
Below is the php form handler if this helps at all: <?php $name = $phone = $package = $beatQuote = $uploadedFile = $message = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = test_input($_POST["name"]); $phone = test_input($_POST["phone"]); $package = test_input($_POST["package"]); $quote = $_POST["quote"]; $message = $_POST["message"]; $uploadStatus = 1; if(!empty($_FILES["attachment"]["name"])){ $targetDir = "uploads/"; $fileName = basename($_FILES["attachment"]["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); $allowTypes = array('pdf', 'doc', 'docx'); if(in_array($fileType, $allowTypes)){ if(move_uploaded_file($_FILES["attachment"]["tmp_name"], $targetFilePath)){ $uploadedFile = $targetFilePath; }else{ $uploadStatus = 0; echo json_encode(array('success' => 0)); } }else{ $uploadStatus = 0; echo json_encode(array('success' => 0)); } } if ($uploadStatus = 1) { $toEmail = 'email@address.co.uk'; $emailSubject = 'Contact Page Enquiry'; $headers = 'From: Contact Page <noreply>'; $bodyParagraphs = '<h2>Contact Request Submitted</h2> <p><b>Name:</b> '.$name.'</p> <p><b>Phone:</b> '.$phone.'</p> <p><b>Package Of Interest:</b> '.$package.'</p> <p><b>Customer Ticked Beat Quote Box:</b> '.$beatQuote.'</p> <p>'.$message.'</p>'; if (!empty($uploadedFile) && file_exists($uploadedFile)){ $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $bodyParagraphs . "\n\n"; if(is_file($uploadedFile)){ $message .= "--{$mime_boundary}\n"; $fp = @fopen($uploadedFile,"rb"); $data = @fread($fp,filesize($uploadedFile)); @fclose($fp); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: application/octet-stream; name=\"".basename($uploadedFile)."\"\n" . "Content-Description: ".basename($uploadedFile)."\n" . "Content-Disposition: attachment;\n" . " filename=\"".basename($uploadedFile)."\"; size=".filesize($uploadedFile).";\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; } $message .= "--{$mime_boundary}--"; $returnpath = "-f" . $email; $mail = mail($toEmail, $emailSubject, $message, $headers, $returnpath); @unlink($uploadedFile); } else { $headers .= "\r\n". "MIME-Version: 1.0"; $headers .= "\r\n". "Content-type:text/html;charset=UTF-8"; $mail = mail($toEmail, $emailSubject, $bodyParagraphs, $headers); } if ($mail) { echo json_encode(array('success' => 1)); } else { echo json_encode(array('success' => 0)); } } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?>
-
Webforms and File Upload Handling With Ajax
Hi there, I have created a webform, which when submitted sends to email. I have included ajax to handle the notifications. But it's not quite working when a file is attached. It sends to email fine when it's just text If I include the form handler contactForm.php directly in the html page with the form, it sends the form attachment fine. If I include a console.log(file) just above the ajax, it does display the file data Below is the code in question: <form enctype="multipart/form-data" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <input class="file-input" id="fileUpload" name="attachment" type="file"> $('form').submit(function(e) { e.preventDefault(); var formData = new FormData(this); if($('#fileUpload').prop('files').length > 0) { file =$('#fileUpload').prop('files')[0]; formData.append("attachment", file); } console.log(file); $.ajax({ type: "POST", url: '/_partial/contactForm.php', data: formData, success: function(response){ var jsonData = JSON.parse(response); if (jsonData.success == "1") { $('.notification').fadeIn(function(){ $(this).addClass("is-success"); $(this).text("Thank you for your interest. We will get back to you soon."); $(this).delay(5000).fadeOut(); }); } else { $('.notification').fadeIn(function(){ $(this).addClass("is-danger"); $(this).text("Something went wrong. Please try again later"); $(this).delay(5000).fadeOut(); }); } }, cache: false, processData: false, contentType: false, }); $(this).trigger("reset"); }); Please let me know if anything looks suspect!
-
Favoured Static Website File Structure
Is there considered a standard for structuring a flat, static website directory structure these days? I mean in the past it was simple index.html /images /js /css but now with compiled files etc, would something like the following be acceptable? index.html /source /scss /js /images /images /js /css
-
Embedded Offsite Blogs
It would be great if there was an alternative method to adding new content the didn't scupper SEO and didn't require a full-blown CMS. Just seems a quantum leap to go from an 8 file website to 30,000 plus file website with security concerns just for the occasional post/text change.
-
Embedded Offsite Blogs
Ok @fisicx thank you. Makes sense but was worth checking. What would be the best lightweight CMS that allows custom design/templates these days?
-
Embedded Offsite Blogs
Just wondering: If I could set up a blog on say blogger, and set it so search engines couldn't crawl it, then parsed the rss feed of that blog to php and and displayed it on a static website, would that static website get the credit for displaying updated unique content? And if I were to do this, can anyone recommend any tools to achieve it? Thanks
-
Feed from specific Facebook Groups and Pages
This may be a slightly daft question, and in a way hopefully it is so it isn't too difficult to answer! I was wondering what the best way of separating updates from a specific selection Facebook groups and pages from my main feed was? I am finding info from pages and groups is getting lost within posts from friends and is quite frustrating! I thought of RSS, but groups don't have feeds it seems? Is there an app out there that helps with this? Suggestions appreciated! Thanks
-
Placeholder for unloaded images
Ah this is great, will give the javascript solution a go as this will probably be more suitable for the project. Many thanks!
-
Placeholder for unloaded images
Hi there, I am hoping to achieve something like on the bbc website, where all images have a grey area of the correct dimensions so the page holds its structure before the images are loaded and doesn't 'pop' into shape. I would've thought this was fairly straightforward but when working responsively you can't simply set the width and height of the frame like you used to! How would I go about this? Thanks!
-
Center aligned div
Should be easy right? Am not sure what I'm doing wrong here, but the div with the form in on this page is refusing to align centre: http://www.southeast.bike/form.html The form pretty much fills the div at full screen so appears central, but shrinking the browser width will reveal that it hangs left. Essentially these are the 2 parts of css that are of interest: .homesearch-wrap{position: relative; float:left; width: 100%; margin-top: 200px;} .homesearch{float: none; width: auto; display:inline-block; margin: 0 auto;} If someone can help it would be greatly appreciated! (I am using the foundation5 css framework)
-
Responsive design preview software/app?
Hi all, Looking for some advice here: I produce photoshop mock-ups from design briefs and display them in software online (currently use cageapp.com) where myself/sales/client can make notes on page elements in our own time on design tweaks. However with the incoming of responsive and mobile first platforms, it seems a little old hat to just give a mock-up of a desktop version of a site. We looked at Adobe Edge Reflow, the drawback here is the lack of support with preview software. I have heard before of designers supplying the customer with html/css versions to the customer so they can preview how the site would behave in browser. Whilst this sounds good, it doesn't allow for the note adding and doesn't fit in our current site development model. Is there software out there that would fulfil these requirements? Thanks.