Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Harmster

  1. Hey hi hello, And here I am again with a new question So I've been making a check for a balance check (In Dutch: Saldo) and this basicly checks all transactions made over a time and adds or substracts an amount to a variable which in the end gets returned... Simple right? No. The selector I user to select all the transactions from a user does not always work. this is my Selector: $transacties = wire('pages')->find("template=transaction, users=$user->id"); Straight forward I thought. When I add a new transaction page with the user ID of someone else it doesn't get added to $transacties Then I change the user ID to mine (the logged in user) it gets added so far so good BUT when I change it back to some other ID it still gets added... I don't get it. I figured the selector must still select it somehow.. but why and how? --EDIT Just to be clear, the $user->id is from the argument in a method... also tried to use this different namings etc but that wont do much. public function get_saldo($u) { $user_saldo = 0; $transacties = wire('pages')->find("template=transaction, users=$u->id"); I can't make any errors in this part since there's money involved. Please can someone answer this question? Much appreciated, Harm.
  2. Hey PW people! I made a custom login form which sends a request to an AJAX page that should log me in, I'll post the scripts in a second. But I'd get a weird error of some sort. This is what I do I log in on my login form (/user/login) It logs me in, session is created and everything I go to the homepage -> i log out -> i go back to the login page and i login again, this is where i can't login i get a message "Incorrect password and username"(my custom message which is returned at a NULL return which means it fails right?! So these are my scripts Login.php: <?php if(!$user->isLoggedin()) { ?> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#login").click(function(){ $("#ajax").html("Laden..."); $.ajax({ url: '/site/ajax/ajaxResponder.php', type: 'post', dataType: 'JSON', data: { 'action': 'login', 'username': $("#username").val(), 'password': $("#password").val() }, success:function(data){ alert(data.pass); if(data.status) { window.location = "/"; } $("#ajax").html(data.message); } }); return false; }); }); </script> <?php ?> <form action ="" method="post"> <label for="username">Gebruikersnaam:</label> <input type="text" name="username" id="username" /> <label for="password">Wachtwoord:</label> <input type="password" name="password" id="password" /> <input type="submit" value="Login" id="login"/> </form> <div id="ajax"></div> <?php } else { echo 'Je bent ingelogt.<br /><a href="/user/logout">Log uit</a>'; } ?> This is ajaxResponder (the part that matters, the case in a switch $_POST['action'])(/site/ajax/ajaxResponder.php) case 'login': $pass = $_POST['password']; $user = $_POST['username']; $r = wire('session')->login($user, $pass); if($r) { $re['message'] = 'U bent ingelogd'; $re['status'] = true; } else { $re['message'] = 'Uw gebruikersnaam of wachtwoord is onjuist'; $re['status'] = false; } echo json_encode($re); break; So what can I do to fix this problem? Kind regards, Harm.
  3. Thank you for your response, I forgot about the cheatsheet i guess... still new to all this... Although I did edit the template and I did make some custom classes to do some repetative actions on that template etc.
  4. Thank you for your quick reply! yeah, i kind of made my own classes to get a bunch of repatative stuff done. I feel stupid that it is that simple... Ty Ryan!
  5. Hey, I am quite new to Processwire and to this forum ,as you can see. Although I am really starting to become a fan of processwire. But the amount of topics on the forums is somewhat limited. Doesn't matter but I can't really find the answer to my question. I do want to retrieve all the fields (type's and values) from a page, and display them. I do got this: <?php $u = new nubUsers(); if($u->is_manager()){ $id = $input->get('id'); $p = new NubPages(); $r = $p->edit_page($id); $f = $fields->find("page=$r->id");//get all the fields ?> <h1>Edit page <?php echo $r->title; ?></h1> <?php }else{ throw new Wire404Exception; } ?> With edit_page would be: public function edit_page($id){ $p = wire('pages')->get("id=$id"); return $p; } How could I get this done? Sorry if this is already answered, explained somewhere else or anything like that, but if so i couldn't really find it :\ Kind regards, Harmster.
  6. Saw that you did edit the post, It works now Big thanks all of you!
  7. yeah thats what I want, I think im just doing something wrong here because it is not working... This is what i have now: public function check_username($username){ $users = new User(); $u = $users->get("email=$username"); if($u->id) { return "Already taken!"; } } And i get this again: I am sorry if I just dont see it or am really bad D: (BTW it is a MODULE)
  8. Hey PW community, This will be my first post so please don't be to hard on me So here's the thing, I've been working with PW for 2 days now and I am trying to make a custom user model for the repetative actions throughout my website, ofcourse using the User from PW. Now I want to register a new user into the user Pages (I think thats how you guys call it, not sure x3) Well that works but now I want my class to check if the username already exists, and thats where I get stuck. Normally I would just run a query and see if it returns more then 0 but I am not sure what to use in a model. This is kind of what I tried. public function check_username($username){ wire('users')->find('email=username'); return $users; } Returns nothing, except for a error: And this: public function check_username($username){ $users = new User(); $users->find('email=$username'); return $users; } Returns a zero + the earlier mentioned message. So could someone please tell me what my options here are? Oh and the username = always the email address so dont worry about that. ;3 Greetings, Harm.
  • Create New...