Jump to content

davo

Members
  • Posts

    283
  • Joined

  • Last visited

Everything posted by davo

  1. Another night wasted; another lesson learned.... I think I have solved my own problem. I only hope this may help someone else one day. There were a lot of things wrong with the code above and the problem I initially thought existed really wasn't the problem at all. $this_user = wire('users')->get($me) That was my problem i think. That returned all users to the array. 'Get ' of course returned the first user, which always happened to be me. And that was why I thought it was working, when actually nothing was working at all! $this_user_id = wire('users')->get("id=$me") That is how it should have been I think....
  2. function myscore($me) { $this_user = wire('users')->get($me) ; // $me is passed from the referring page and should be the id of the current user $myscore = $this_user->score; // there is a field on the users page called which this grabs echo "<p>Your score is $myscore</p> "; // it works, the score is output } function myrank($me) { $this_user = wire('users')->get($me); //$me is again passed as the value of the current user $myscore = $this_user->score; // my score grabs the score from that users page $users_greater_than_me = wire('users')->find("score>=$myscore"); // this finds users who have a higher score than the current user $myrank = count($users_greater_than_me); // myrank counts those users echo "<p>Your rank is $myrank my and score is $myscore </p> "; // rank is output correct but myscore doesnt output anything } I've got two function which should be doing exactly the same job but one works and yet the other doesn't I don't even really need the second one but it's frustrating me why it's behaving like this. As you can see above, myscore works in the first function It also works in the second function for comparing users but when I ask it to output it a third time it's blank. Why oh why?
  3. davo

    login user

    In fact, I compromised on this. I've used the persistent login, but also dropped a cookie with the user ID. If the user is not logged in, the cookie user ID will be used instead for simple site functions, but obviously in inviting the user to log back in for full function.
  4. davo

    login user

    Makes SENSE. Cheers.
  5. davo

    login user

    yes it would and thanks. but out of interest, why was my login not working?
  6. I'm trying to make logging in a bit easier for users. I've tried dropping a cookies with the user's id and hashed password if the user is logged in, and if they're not logged in, pick up the two cookies and use them to log the last user in. <?php session_start(); if($user->isLoggedin()) { $me = $user; $pass = $user->pass; setcookie("id",$me,time() + 500); setcookie("pass",$pass,time() +500); echo "it is $me and $pass"; }else{ if($session->login($_COOKIE["id"],$_COOKIE["pass"])){ echo "you in";} echo $_COOKIE["id"]; } ?> It doesn't seem to be working though. Where have I gone wrong?
  7. Thanks teppo. I have tried the other operators but I can't find anything that matches exactly right. Partly my fault I guess for not organising the data properly in the first place. The perfect example is as above: it finds a page with 'Oman' on the 'Romania' because it contains the word r Oman ia I did think about adding a space after the query like this $q =$q . " " But that would then exclude the words or my keyword field which are going to have a comma directly after them. I guess I could make up two instances to search for, one with a comma appended and one with a space.
  8. I'm using the following for a search query $matches = $pages->find("Meta_keywords|DMCcontact_Country|DMCcontact_Address_2|DMC_Email%=$q, template=dmc, limit=50"); The problem I have is it's picking up parts of words within other words like this: oman, brings back romania Any ideas how i could improve this? David
  9. Depends where you want to start with this really. The very simplest way would be to use Ryan's form builder module. This form could be made available only to each of your two types of users that can create other users. The form builder can publish straight to pages. Users are also just pages. Just make two identical forms, one for managers and one for supervisors; the only difference being one has extra options in the role drop down. Just make sure your fields match the 'user' page fields. Or, it's fairly simple to make your own user registration page. Create a form in html. Post the form back to the same template and process it. You'll find $user->hasRole($role) useful. Here's a simple example from the docs: <?php $u = new User(); $u->name = "gonzo"; $u->pass = "BamBam!"; $u->addRole("guest"); // substitute this for your worker, manager or supervisor role $u->save(); Both are pretty simple. Personally, I'd start with the do it yourself method so you understand how pw works better. You'll find lot's of help if you have a go.
  10. I used ispconfig as a control panel. This runs nightly backups of the database and content. It the tar balls these. I then use scp to copy them from one server to another and then untar them.
  11. is there something in /site/sessions ? that might affect this? try deleting the sessions.
  12. OK, I think I got there in the end. I think it's still messy but I it does seem to work. For info of anyone that wants to do the same: $hours_flight = $input->get->hours_flight; // this comes from the slide $time_difference = $input->get->time_difference; // this comes from the other slider $specialism = $input->get->specialism; // this comes from a form builder using ASM select if($specialism){ $special_selector = ", DMCstats_Specialise_In="; foreach ($specialism as $special) { $special_selector = $special_selector . $special . "|"; } $special_selector = rtrim($special_selector, "|");}else{ $special_selector = "";} ?> $negative_time = $time_difference - ($time_difference * 2); // time difference uses a signed integer $matches = $pages->find("template=dmc, DMC_Average_Flying_Time_hours<=$hours_flight, DMC_Average_Flying_Time_hours!='', DMCstats_GMT<=$time_difference, DMCstats_GMT>=$negative_time $special_selector"); // im after all pages that are less than or equal to the flight time, less that time difference and greater than the negative time difference which renders me a page like this: http://www.dudmc.com/dmc-hunter/ ...plus there's something wrong with my divs, but that's for another day.
  13. Trying to think of this with a clearer head this morning, I think I could do something like this. Open the specialise[] get array and create a selector variable. Then paste that variable into the selector for the pages -> find command. I think it should work, but it's going to feel quite messy. Is this the only/best way? I've not tried it, but it would look a bit like this: $specialise = $input->get(specialse[]); $special_selector = "specialism="; foreach ($specialse as $special_item) { $special_selector = $special_selector . $special_item . "|"; } $special_selector = $special_selector . ","    $search_results = $pages->find("$special_selector") just feels messy
  14. I've used form builder to create a form but but this isn't really a form builder question as I'm processing my own form. I've created a form that submits a multi value field back to itself called specialise[]. How can I then use that array to filter a multi page field array and return only pages that have any of the specialise[] values? A dmc page may have many specialise values by page select type. The specialise[] array in the get input again may have many values. This is my attempt so far but I'm not sure how I'd use $matches =$pages->find("timedifference, flightbit, --here i want to compare the specialise[] array to see if any values are in the specialise array") The field I want to search is DMCstats_Specialise_In which is multiselect page type. <?php /** * Page template * */ include("./dmcheader.inc"); $hours_flight = $input->get->hours_flight; // this comes from the slide $time_difference = $input->get->time_difference; // this comes from the other slider $specialism = $input->get->specialism; // this comes from a form builder using ASM select ?> <div class='container'> <div class='row'> <div class='col-md-6'> <!-- load in the form builder form --> <?php echo $forms->load('advanced_search')->render(); ?> <?php $modules->get('JqueryCore'); // ...or load your own jQuery $config->styles->append($config->urls->root . "wire/templates-admin/styles/inputfields.css"); $config->scripts->append($config->urls->root . "wire/templates-admin/scripts/inputfields.js"); $config->styles->append($config->urls->FormBuilder . 'form-builder.css'); $config->scripts->append($config->urls->FormBuilder . "form-builder.js"); foreach(array('jquery-ui', 'inputfields', 'main') as $file) { $path = $config->paths->FormBuilder . "themes/start/$file"; $url = $config->urls->FormBuilder . "themes/start/$file"; if(is_file("$path.css")) $config->styles->append("$url.css"); if(is_file("$path.js")) $config->scripts->append("$url.js"); } foreach($config->styles as $file) echo "<link rel='stylesheet' type='text/css' href='$file' />"; foreach($config->scripts as $file) echo "<script type='text/javascript' src='$file'></script>"; ?> </div> <div class='col-md-6'> <?php $negative_time = $time_difference - ($time_difference * 2); // time difference uses a signed integer $matches = $pages->find("template=dmc, DMC_Average_Flying_Time_hours<=$hours_flight, DMCstats_GMT<=$time_difference, DMCstats_GMT>=$negative_time"); // im after all pages that are less than or equal to the flight time, less that time difference and greater than the negative time difference $countresult = count($matches); echo "$countresult DMCs matching your search $specialism[1]"; echo "<ul class='list-group'>"; foreach($matches as $match) { echo "<li class='list-group-item'><a href='{$match->url}'>{$match->DMC_country_represented->title} - {$match->title} - $match->DMCstats_GMT time difference | $match->DMC_Average_Flying_Time_hours flying time </a></li> "; } echo "</ul"; ?> </div> </div> </div> </div> <!-- end container --> <?php include("./dmcfooter.inc");
  15. Here's a result from last year on a PC that I build hard wired with cat6 cable back to my dell switch to my edge router lite.On occasions though upload download ratio can be much more synchronous - a lot depends on the load on the server that your testing against at that time eg time of night, location etc. Sadly the PC I built was a present for someone and now I'm back to my ancient hp laptop. It does mean though that I can have as many devices on my home network all sucking some internet without affecting each other. You could enjoy 0 latency call of duty.. shame I can't shoot for toffee lol
  16. I'm very lucky indeed. The town I'm in started as project some years ago putting fibre into mini trenches. When you sign up contractors extend the trench into your home and run a piece of fibre into your house. They boast gigabit speed but I've only managed 880 Mbps on borrowing a friend's MacBook with an ssd. www.gigler.co.uk I can watch 100+ movies at once lol. It won't be long hopefully once bt have replaced their core networks that they will eventually extend fibre into the home for everyone.
  17. I wish i was this creative!
  18. Upgrading processwire... in just 3 minutes
  19. Sure. Maybe pass the currency via the URL and use that to change the output See the currency link on this page: http://www.dudmc.com/region/europe/accent-travel-romania/
  20. I'm using html 5 to create a range slider for a form but it doesn't work across all browsers. I think I remember seeing somewhere a way to use the admin parts in templates. Is this simple? Anyone have an example?
  21. Adrian - superb! I guess the problem with having a separate currency symbol on a different line could cause problems when you use the module round the other way and rather than asking for a conversion with symbols you can pass it country names to return symbols I think.. meaning it may bring back two. but for me.. solver it perfectly. Cheers
  22. Thank you. I need some sleep now so I'll have to recommence tomorrow. Cheers
  23. 2014-09-25 18:51:38 guest http://www.mysite.com/facts/currencies/mexican-peso-mxn/ Error: Call to a member function error() on a non-object (line 301 of /var/www/clients/client2/web37/web/site/modules/ServiceCurrencyConversion/ServiceCurrencyConversion.module) this is the error log entry
  24. After having a fair bit of hunting around... no I'm using apache2 php5 on debian. /var/log seems to hold most of them but nothing obvious
  25. Unfortunately that didn't seem to make any difference. I commented out the original function and added your adapted one in like so: /** public function convertAdvanced($fromCurrency, $toCurrency, $amount, $markup = 0.0, $decimals = -1) { * $rates = $this->getConvertedRatesTable($fromCurrency, $amount, $markup, $decimals); * if(!isset($rates[$toCurrency])) throw new WireException("Can't find target currency."); * return $rates[$toCurrency]; * } */ public function convertAdvanced($fromCurrency, $toCurrency, $amount, $markup = 0.0, $decimals = -1) { error_log(print_r($rates,true)); error_log("ToCURR:".$toCurrency); $rates = $this->getConvertedRatesTable($fromCurrency, $amount, $markup, $decimals); if(!isset($rates[$toCurrency])) throw new WireException("Can't find target currency."); return $rates[$toCurrency]; } but still received the following for MXN: Error: Exception: Can't find target currency. (in /var/www/clients/client2/web37/web/site/modules/ServiceCurrencyConversion/ServiceCurrencyConversion.module line 304) #0 /var/www/clients/client2/web37/web/site/modules/ServiceCurrencyConversion/ServiceCurrencyConversion.module(319): ServiceCurrencyConversion->convertAdvanced('GBP', 'MXN', 250, 0, -1) #1 /var/www/clients/client2/web37/web/site/templates/currency.php(16): ServiceCurrencyConversion->convert('GBP', 'MXN', 250) #2 /var/www/clients/client2/web37/web/wire/core/TemplateFile.php(140): require('/var/www/client...') #3 [internal function]: TemplateFile->___render() #4 /var/www/clients/client2/web37/web/wire/core/Wire.php(359): call_user_func_array(Array, Array) #5 /var/www/clients/client2/web37/web/wire/core/Wire.php(317): Wire->runHooks('render', Array) #6 /var/www/clients/client2/web37/web/wire/modules/PageRender.module(337): Wire->__call('render', Array) #7 /var/www/clients/client2/web37/web/wire/modules/PageRender.module(337): TemplateFile->render() #8 [in
×
×
  • Create New...