• Content count

  • Joined

  • Last visited

Community Reputation

3 Neutral

About Junitar

  • Rank
  1. Thank you very much for the example!
  2. Thank you very much for your input and for the link. I will test it as soon as my site is online. 1a and 2b (after switching <section> with <article> and vice versa) would then be the best options. What do you think about wrapping the orange and red elements into a <section> like in 1a? Knowing that there won't be any other <section> in the <main> tag, do you think it still makes sense or it's just unnecessary? I would tend to say it's unnecessary, can you confirm that?
  3. Hello, I’m restructuring the html code of my site to have the best semantic markup as possible but I struggle with the <article> and <section> tags. I know there are lots of documentations on the internet on how to use these tags. I’ve read many of them but the more I read about <article> and <section>, the more I get confused on how to use them properly, mainly because I’ve seen a lot of contradictory examples from a site to another. I understand that a <section> is used to regroup elements sharing information on a similar thematic whereas an <article> refers to an independent content that is reusable outside the document. It sounds simple in theory but in practice, it's very tricky, at least for me. I’ve made different templates of my "about" page which is he most complex page I have (in regard to semantic), and I would appreciate if you could tell me which of the following images is the most semantically correct or if you have other suggestions I could take into consideration. Beside the <section>/<article> thing, I also question myself on the need of using a single <section> in the <main> container… Do I need to regroup all my "about" elements inside a <section> tag if there is no other <section> in the document? Fig. a Fig. b and 4b -> just like 3b with the blue containers being different <section> instead of being different <article>. 4b is how my page is currently structured. Any help would be appreciated. Thanks!
  4. I'm not a PHP expert but for your first question, I would recommend you to use the FilesystemIterator class (implemented in PHP ≥ 5.3). I've just finished doing an image gallery for my project and this is the easiest, most straigth-forward approach I've found. Here is an example on how to use it: $dir = '/yourDirectory'; $fileDir = new FilesystemIterator($dir); // creates a new instance of the class as $fileDir foreach ($fileDir as $file) { if ($file->getExtension() == 'jpg') { // lists all .jpg in $dir echo '<img src="'.$file.'"/> '; } } Hope that helps.
  5. Works like a charm. Thank you very much!
  6. Hi, I would like to list all the items contained in a folder except for 2 or 3 specific ones. For example, let's say I've item 1, item 2, …, item 10 in /myFolder. I would like to list all the items of /myFolder but item 1, item 3 and item 4. I've come up with the following code which does the work but looks a bit awkward. <?php $dir = '/myFolder'; $filesDir = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS); $fileName = ''; foreach ($filesDir as $file) { $fileName = $file->getBasename(); if ($fileName != 'item1' && $fileName != 'item3' && $fileName != 'item4') { echo $fileName.'<br>'; } } Is there a simple and more elegant way to accomplish this? Any help would be appreciated, thanks!
  7. Thanks for the clarification! Everything's clear.
  8. Thank you very much Ingolme for your example, I understand it now! Yes, I guess it's a good enough reason. Sorry if my question was dumb but I wanted to understand why it was a bad thing not to initialize variables first. I started learning PHP 2 days ago and I don't have enough experience in programming to know it could cause a program to crash. I got it now anyway, thanks.
  9. Thank you to you both for your thorough feedbacks. I'm afraid it's still a bit fuzzy in my mind right now and the fact my English is limited sure doesn't help. I understand that a variable is used to store a content and it doesn't make sense to call a variable that doesn't exist. But in my example, I declared my variables later in the code: … $errors['name'] = 'alert'; … $name = sanitize_input($_POST['name']); … $email = sanitize_input($_POST['email']); … this is why I don't completely understand the need of specifying at the beginning that $errors = [], $name = '', $email = '', etc. If I write: <?php $test['letter1'] = 'a'; $test['letter2'] = 'b'; print_r($test); // the output is Array ( [letter1] => a [letter2] => b ) my array is well declared and ready to be used without being initialized using $test = []. I guess the answer to my question is somewhere in and
  10. Hello, I've just read the tutorial on how to process a form in PHP, available on this site, and I was wondering if there's a specific reason to declare empty variables (or arrays) at the beginning? I don't understand what is the point of doing so. For example, in the following code, why would the 2sd and 3rd lines be necessary? <?php $errors = []; $name = $email = $message = ''; if (condition) { $errors['name'] = 'alert'; } else { $name = sanitize_input($_POST['name']); if (new_condition, $name) { $errors['name'] = 'new alert'; } }
  11. Thank you to confirm my thoughts. I had a doubt after I stumbled upon an old thread on stackoverflow where a guy implied this kind of code was possibly flawed.
  12. Hi, I'm new to PHP and I was wondering if it's perfectly safe to use $_SERVER['PHP_SELF'] like so: <body<?php if(basename($_SERVER['PHP_SELF']) == 'home.php') echo ' class="home"'; ?>> … </body> As far as I understand, the $_SERVER['PHP_SELF'] variable can only be exploited when used as a link or in a form/inputs, where the variable should be wrapped into htmlspecialchars() to counter XSS attacks, am I right?
  13. Hi, I'm making a responsive centered tiled gallery for my website. For aesthetic reasons, I only need to have a margin between the images. To do so, I set a left margin to each elements but the first, in each row, using the :nth-child() selector. I got it to work as I wanted to but I'm now facing a problem with the image captions which break the floating elements if I enter too many words in them. Please, see the jsfiddle example here: https://jsfiddle.net/0w379712/ How can I do to prevent this? Ideally, I would like to have the entire row going down if there's too much text above. I thought a clear: left in the last-child of the row would fix this but it's not working. Also, would you recommend to use the :nth-child() or :nth-of-type() selector to achieve this? I've analysed several web galleries with similar mosaic and none of them used these kind of selectors. Probably for browser compatibility reasons, but can't say for sure. Edit: I finally managed to fix the problem using .tile:nth-child(2n+1) / .tile:nth-child(3n+1) { clear: left }, I messed up with the syntax of the selector in my previous attempts…
  14. I've just tested again your suggestion and it works indeed. Don't know exactly what I previously did. I guess my brain just needs some rest right now, I've done too many exercices today, it's a big mess in my mind
  15. Thanks for the help, I've already tried btn.attr("title", currentText == "menu" ? "close menu" : "menu"); but it didn't work properly (the title changed to "close menu" when it should be "menu" and vice versa). Anyway, I've just found what I was doing wrong… btn.attr("title", btn.attr("title") == "menu" ? "close" : "menu"); is now working fine but I formerly called my button title "Menu" with a capitalized "m", while I used a small "m" in the btn.attr() which screwed it all.