Jump to content

slashadmin

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by slashadmin

  1. I wanted to know if there is an easy way to generate the URLs for my links. I'm now using plain PHP functionality: $params = array_merge($_GET, array("limit" => 10)); $new_query_string = http_build_query($params); Thanks for your help!
  2. Hi everybody, I have got a (hopefully) pretty simple question but I can't find a "clean" solution for it and hope you can help me. I'm using a form to let the user specify different variables (Get Request) and show them the according pages. It's more or less similar to the Skyscraper Demo page. Now I'd like to add three links to set the limit of my query. So if the user clicks on e.g. 10 -> only 10 pages should be listed (leaving the other variables the same). I'd like to generate links with the current URL but change the limit variable. Is there a function to get the current URL with all the get parameters and let me change/add one of them? Or do you have any other suggestions how I could add this functionality? Thanks for your help!
  3. Thanks for your help. I'm now using the direct database implementation and it works great with much leaner code than I had before. $r=$db->query('SELECT pages_id, ('.$user_location->lng.'-lng)*('.$user_location->lng.'-lng) + ('.$user_location->lat.'-lat)*('.$user_location->lat.'-lat) AS "distance" FROM field_map_location ORDER BY distance'); $ides=array(); while($row=$r->fetch_row()) $ides[] = $row[0]; $query = 'id=' . implode('|', $ides); // Output: 1075|1070|1074 $locs = $pages->find($query); foreach($locs as $result) { echo "{$result->id}|"; //Output: 1070|1074|1075 } However, there is still one problem left. If I look at the $query, the IDs are in the right order (based on their distance to the $user_location) but as soon as I echo them out in the foreach loop they are ordered by ID. I guess that the $pages->find function automatically orders the pages if no 'sort' variable is given. Is there a way to sort them according to the query string?
  4. Hi, I'm using ProcessWire for the first time and I'm pretty impressed. Very cool CMS. But now I ran into a problem and hope you guys can help me. I'm creating a "Shop Locator" -> a page which includes a list of shops (including pagination) and a map of them (The shops are child pages including the MapMarker Field). So far so good but now I'd like my users to be able to enter their Address and order the Shop-list according to their distance to the next Shop. I already got the google api working so I've got access to the long/latitude values of the users address. I tried to calculate the distance directly in the $pages->find() function but it doesn't work. $results = $pages->find( "parent=/shop-locator/stores/ sort=((map_location.lng - 16.70088) * (map_location.lng - 16.70088) + (map_location.lat - 48.36351) * (map_location.lat - 48.36351))"); I also tried to create a new page array object and reorder the entries. It worked to order the list the right way but broke my pagination (displayed the entries of the first page on every page). Also this method had a lot of overhead. Does anyone have an idea how to do that? Thanks!
×
×
  • Create New...