Jump to content

bwakad

Members
  • Posts

    450
  • Joined

  • Last visited

Everything posted by bwakad

  1. 1, 2, 3, 4, and back to 1 ... The only way I could make this work is using this following code, which on a refresh/reload does not give popus asking to re-send info again. I guess it is only doing that on post method... it will output url like this: "path/?view=list" which are urlsegments. // menu buttons in header <form action='./'> <input type='submit' class='button' name='view' value='list' /> <input type='submit' class='button' name='view' value='grid' /> </form> // and in the top of content(ps. using GET bevause I did not set POST in form)... if (isset($_GET['view'])) { switch ($_GET['view']) { case 'grid': $layout = 'grid'; echo $layout; break; case 'list': $layout = 'list'; echo $layout; break; } } else{ $layout = 'grid'; } So, I have: $selector = "template=member-profile"; // here I need to build a switch // based on fields (example if someone clicks on 'bodytype') // a little further ... $selects = $pages->find($selector); // at the end ... include ("./inc/{$layout}.inc"); // and inside the layout file ... etc foreach ($selects as $member) { ?> But everytime this runs with something new in the selector, the urlsegment get lost... I was thinking to use whitelist to 'remember' the value, and have: $this->input->whitelist("view", $this->input->get->view); but don't know how to continue...
  2. Maybe I am on a different track... I have two files: grid.inc + list.inc , Both have their own php and css As it stands now (default) the include("./inc/".$layout.".inc"); is reading include("./inc/grid.inc"); This should also be when the button "grid" gets clicked. Is not working... When the button "list" get clicked, I need it to include "list"... and should read include("./inc/list.inc"); Is not working... - edit -Provide console output ?? were can I find that ?? using FF found it, but did not display ANY errors...
  3. @MadeMyDay - I think your code is okay, did not work for some reason ... placed the script in footer, the session BEFORE any output, after that the buttons in the header and the include() in my template for content This next part I do not understand, it supposed to be the css layout (do not need), because should be already set in $layout which will be included. Or am I going with this the wrong way? <div class="myView"> <?= $layoutview ?> </div> But I actually need to pass variable ( "grid" or "list" ) to $layout; Set session for this value; And then include the file with my php/layout. Judging from the session code this: include("./inc/{$layout}.inc"); is working once, buttons does nothing...
  4. This I read. But what I mean is: how to attach a session to my variable using a button / link. And then this: Using a link I do not need a a form, but my url get's assigned either a # or #something or /page/ ... Using a form I don't have this in the url, BUT after the submit, when refresh the page, the form get submitted again (message poppup)... - edit - I could of course make a link go to the same page !!! - end edit - The only thing I found (almost the same as what I had) was this : // before anything is outputted if($input->post->layout) { // set the layout $session->layout = $sanitizer->pageName($input->post->layout); } // where the buttons/links are if($session->layout == 'grid') { $layout = './inc/grid.inc'; } else if($session->layout == 'list') { $layout = '.inc/list.inc'; } else { // should there not be a session here as well? $layout = './inc/grid.inc'; }
  5. From what I understand, if cookies are disabled by client, they will not have effect. Then, sessions would be good, but are for loggedIn only...? I can't really find info on how to work with sessions in PW...
  6. It's maybe offtopic, but anyway... I was looking for a way to have 2 buttons. Idea is to dynamically include layouts based on those buttons clicked. - one for GRID layout - one for LIST layout - I need a php variable for this... Jquery and ajax allow to change DOM elements as in HTML. But PHP get parsed as HTML so no dynamic php variable would be changed since the page is already processed. Developers at google are very strict on different views (layout) and url segments, because it lead to same content... For now I think there are 3 ways to do this: 1 - a href links - problem: url is attached to end, and on every page load, or field selector, the $layout variable is reset. 2 - url segments - problem: url is attached to end, and on every page load, or field selector, the $layout variable is reset. 3 - form with post - problem: on page refresh, the form get's re-send which I do not want. Then again, maybe this would suit better in a cookie... but I really have no idea as how to do that. code what I have now: // menu <form action='./' method='post' id='layout' novalidate> <div class='small-2 columns'> <button type='submit' name='submit_list' value='list' id='list' class='button tiny right'>List</button> </div> <div class='small-2 columns'> <button type='submit' name='submit_grid' value='grid' id='grid' class='button tiny right'>Grid</button> </div> </form> // before header is included $layout = "./inc/grid.inc"; if($input->post->submit_list) { $layout = "./inc/list.inc"; } if($input->post->submit_grid) { $layout = "./inc/grid.inc"; }
  7. No, your not confused ... I was just thinking "what is someone developed a site, and does not remember the login anymore". Sorry for the confusing (it's me)
  8. @adrian - I was looking in the config file and see the host details are there, but I gues if one change it, they would need to obtain a new hash for that, AND change the DB as well?
  9. The trouble with browsers, screens and phones are a pain in the ^&*. 1. Browsers control HOW they want to display elements. 2. CSS and HTML5 wants to display their standard for elements. 3. Jquery wants to give you in between solutions. 4. Phones adjust their sizes and each brings their own standards. 5. And every month we go back to 1 again.... I have given up on anything that is not crossbrowser, or cross phone, sort-a-speak ... If we only had 1 browser, 1 screen size, 1 phone and 1 camera, life was so much simpler.
  10. Also this might help you... https://processwire.com/talk/topic/1126-how-to-debug-use-the-error-log/?hl=%2Berror+%2Breporting#entry9954
  11. Only thing I see for username / pass is this.... Name: Any combination of letters (a-z), numbers (0-9), dashes or underscores (no spaces). Pass: Password must be at least 6 characters and have at least 1 letter and 1 digit. Password may not have whitespace. So I guess symbols are not allowed... or maybe keyboard suddenly changed to other language?
  12. This might be a stupid question - and I am considering a question mark on my picture. But I read the http://www.flamingruby.com/blog/processwire-weekly-16/ Then from the PageTable link, I came to this topic, only this topic is ProFieldsTable - so confusing... Ryan mentioned the confusing in this topic and said ...PageTable is part of the ProcessWire core (on the dev branch)... Now, I am running a dev ProcessWire 2.4.11. How does this PageTable look? Where can I find it? Or are we talking here about a newer one (so quick?).
  13. Another thing accomplished! I now use an integer field on frontend - but still need to sanitize this as integer... I use a pattern for this input in format yyyymmdd. Since I also do server side validation for the date, I do not have to worry. For the PW part I have this code below - and if interested, for the functions you should go to phppro.org - they have a clean and understandable layout of code examples which are easy to follow. The $testvalue is as the name suggest, a test. Next thing to consider is, if it is wise to do this calculation on a per page view, because asigning the $testvalue as a static value will lead to unaccurate age display.... how would PW think about that ? // on submit: // no input received, return error if(empty($input->post->birthdate)){ $errorMessage .= "<li><b>Birthdate</b> is required.</li>"; } // birthdate is invalid, return error elseif(validateDate($input->post->birthdate, 'YYYYMMDD') === false ) { $errorMessage .="<li><b>Birthdate</b> is not valid</li>"; } // birthdate is valid, do calculation elseif (validateDate($input->post->birthdate, 'YYYYMMDD') === true) { $dob = $input->post->birthdate; $tdate = date(Ymd); $testvalue = getAge($dob,$tdate); }
  14. so that means I would need to set output format to "none" since I am calling $page->getUnformatted("date"), take the value from that, apply php funtion datetime(), to output "xx" as years. Could use a number field for that I gues.... example: number would be 12031980. Just realized I see integer as field type.
  15. The goal is to have people enter a birthdate, and in the end only displays the current age on their profile. Also people should be able to search on age. So I have 3 things to do this: Format: upon entering in front end - is controlled by regex. This is just the format. Validation: before saving - done by php function checkdate(). This is to see if date excist. Leapyears and dd=32 etc. Age: after validation and saving - calculation is done by php function datetime(). It takes formats from different timezones into consideration. But how to implement this in PW? I know there is a DateTime field. But the output and input formats puzzle me. I need mm dd yyyy where the validate function already take the order of those segments into consideration, and either with or withouth "-" or "/". Does the backend formats affect the frondend inputs? And how to search on this field if I just need the Age (years)...
  16. - EDIT - if I just use plain old html and php (no function) I can simply say $input->post->my-field-variable in the $selected = ... etc. I guess a function to output a select is not a good idea if you want to retrieve back it's value... - END EDIT - I don't know if this is good practise but I made this function so I could simply use: select("myfield"); in my template, which make the code less. Just a reminder, the "select" word I use here is just to make it clear. I use these on a form submit, posting to the same page, and errors get displayed for empty values etc. But I would like to retrieve back the value selected in a select to make it more user friendly. I thought it was the whitelist doing that, but noooo... I tried with input->post->what and no result either. I use this for error checking... $myfield = $input->post->myfield; function select($what) { $pages = wire("pages"); $out = "<select name='{$what}' id='{$what}' aria-label='{$what}' required> <option value=''>your {$what}</option>"; foreach($pages->get("/personal-info/{$what}/")->children() as $what) { $out .= $selected = $what->name == $input->whitelist->what ? " selected='selected' " : ''; $out .= "<option$selected value='{$what->name}'>{$what->title}</option>"; }; $out .= "</select>"; echo $out; }
  17. Oh yeah... /members/ for the path you mean. Forgot about that. Good one!
  18. Got it (must be halfblind). Sorry for that. It now displays nicely in a container at top of the form. try{ $u = $session->login($username, $password); if($u && $u->id) { $session->redirect("/members"); } } catch(Exception $e) { $errorMessage .= "<li><b>" . $e->getMessage() . "</b></li>"; }
  19. Error: Exception: Please wait at least 50 seconds before attempting another login. (in C:\xampp\htdocs\... etc.) As I read through the forum I see it is to stop attemps of brute forcing which is good. But I would NOT like to display this message with the path and all on the front end. So, how to stop it from displaying in front end (without turning it off)? And, in case of login, I was thinking of using something as a counter: Login (attempt 1).. try and failed Login (attempt 2).. try and failed Login (attempt 3).. try and failed, redirect to recover login credentials But what are the conditions. Is this based on a certain amount within a certain time frame? Or just in between logins a certain time?
  20. Hey thanks! Cool site to check patterns.
  21. In a form I use this: elseif (!preg_match("/^[A-Za-z0-9]{6,16}$/", $input->post->password)) { In the backend of PW there is a pattern setting under INPUT tab of the field. But, how to enter this there? Can't find info on that. With slashes: /^[A-Za-z0-9]{6,16}$/ Just beginning and end of string: ^[A-Za-z0-9]{6,16}$ Or only this: [A-Za-z0-9]{6,16}
  22. Thanks, I did it like code below. Had to set (novalidate in my form tag) to test. - EDIT - see also topic SessionLoginThrottle Now, with an empty field is does not matter. But if I check on username (taken), or values based on pregmatch, these values are not sanitized until all is good. Those could be a problem. Should I move the sanitize, or do I use a double sanitize ? Don't know if PW allows double sanitize... if ($input->post->submit_registration) { $errorMessage = ""; // check field and add message to variable if (empty($input->post->myfield) ) { $errorMessage .= "<li><b>myfield</b> is empty.</li>"; } if ( empty($errorMessage) ) { // form details are okay, do my thing } } // before I display the form if ( !empty($errorMessage)) { echo "<p>There was an error with your form:</p><ul>" . $errorMessage . "</ul>"; } // start form here <form action='./' method='post' id='someid' novalidate> // field, and retrieve invalid value back <input type='text' name='myfield' value='<?php echo $input->post->myfield; ?>' id='myfield' />
  23. Hello, For my form I use the standard HTML5 (not echo out) and fields are required in combination with a pattern. I have not a clue if this is supported in all browsers. And I do not know if these validations can be by passed. But hey, we have PW to check submitted fields! The form post to the same page. So if($input->post->username) is excisting in PW while is should be new, I would like to see a message saying that, in stead of returning an empty form with no message. I have tried to search through the forums, used Google as well, but could not find a result since "error" is not just related to a form. I really could use an example how to retrieve errors saying WHAT was not good. Or is everyone using jquery for that?
  24. Had the same trouble with Google.... they stole it!
  25. I wanted to use PW mapmarker.... but for frontend what I needed it was not suited. I now use geocomplete from ubilabs for frontend. Looks great, works excellent. The google api3 docs have an excellent video on retrieving addresses. So in my form I have 1 autocomplete address field that catches Country, State and City level (I explicitly set it to real addresses, NOT from hotels or anything) and use those values to populate fields for members. If any is missing, it would not be valid. Yes, I could use a dropdown (thousands of cities), or use a input field (no way to validate). So this was a good solution.
×
×
  • Create New...