ryan Posted November 2, 2013 Author Share Posted November 2, 2013 I'm having trouble understanding if http://www.synbiopro...ap/marker/3210/ leads to an actual page in PW or if it's just a URL that generates the code on the fly... makes sense? It's using URL segments, where the number (id) is the URL segment. Here's the code from that template if it helps: <?php $id = (int) $input->urlSegment1; if($id < 1) throw new Wire404Exception(); $marker = $pages->get("template=map-item, id=$id"); if(!$marker->id) throw new Wire404Exception(); echo $marker->render(); That $marker Page is a page using template map-item. The map-item template contains the fields for each map marker item like location/coordinates, categories and notes. The implementation of the template file is just to output a <div> with that info in it, and that's what gets sent through that $marker->render() call above, which goes straight through ajax. It's not technically necessary to do it this way, but it does enable us to just pass through an ID on the front-end, since the full URLs take up more space without offering any real benefit in this case. So it's just more efficient to route through a known, consistent URL with an ID appended to it. 1 Link to comment Share on other sites More sharing options...
Peter Posted November 5, 2013 Share Posted November 5, 2013 Thanks Ryan Got it working (as seen here on this dev site: http://178.79.146.18/en/projects/). Thanks also to Adrian for the: $useWrappers = false; In the RCDMap.js I want to set the correct language $.get('/en/marker/' + marker.rcdID + '/', {}, function(data) { Any ideas how I can use a conditional like this inside the .js file?: if($user->language->title == 'no'){ }else{ } I know that I can load different .js files for each language like this: if($user->language->title == 'no'){ echo "<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false&language=no'></script>"; }else{ echo "<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>"; } Link to comment Share on other sites More sharing options...
Craig Posted November 5, 2013 Share Posted November 5, 2013 Any ideas how I can use a conditional like this inside the .js file?: if($user->language->title == 'no'){ }else{ } I would add a JS object to the page in your <head> tag, from your template file. For example: <script type="text/javascript"> var user = {}; user.lang = "<?php echo $user->language->title ?>"; </script> Here, I have specified that user is an empty object, and setting the "lang" property of it to the value from PHP $user->language->title. This way also allows you to add other properties to this should you wish to use more user attributes in the future. You can then access it from javascript as any other object/variable: if (user.lang == "no") { // one thing } else { // another } 1 Link to comment Share on other sites More sharing options...
Peter Posted November 5, 2013 Share Posted November 5, 2013 Thanks Craig, Works great: echo "<script type='text/javascript'>". "var user = {};". "user.lang = '{$user->language->title}';". "</script>"; ... $.get('/' + user.lang + '/marker/' + marker.rcdID + '/', {}, function(data) { Link to comment Share on other sites More sharing options...
Recommended Posts