Guest
05 Jun 2013 04:15

Hi there, I am building a website where people can post a ride with a 'from' and 'to' location. I am using a geo field for this. Now, it is realy essential to have a nice filter module, with two geo fields, one for the start location, and one for the endpoint.

If I make a filter module with only one filter, it works like a charm! But I would like to have two filters, and if I have two geo filters activated their function gets messed up with eachother: - it sort of ignores the to location you put into the first (from) filter - the location you put into the second filter will be displayed into the first filter after you hit the search button. - when moving either the pointer in either the 'from-' or in the 'to' field, you'll see the data in the input id=f_position_lng and other from the first (from) field change. And you never see the data connected to the second (to) field change. - and a lot more strange stuff, but it's hard to explain, please check the website: http://welovehitchhiking.com/index.php/home/hitchhiking

You can also see the first (from) filter is not 'activated' (eg the circle is getting darker, and the map moves to contain the circle) when it is positioned , and the second is. More extreme, the second filter is activated when you move the first cursor.

I'm not shure weather I am doing something wrong, or this is a bug, but I shurely hope you could help me with this ;) Thanks in advance.

Here's the code I am using as a template, inspired by a post on mintjoomla:


<form action="<?php echo JRoute::_('index.php');?>" method="post" name="filterform" id="filter-form"> <legend> From </legend> <?php echo $filters['kc579cb2dc58069b2189ab1f97814de55']->onRenderFilter($section, TRUE); //is the 'from' filter ?> <legend> To </legend> <?php echo $filters['kb3a66c2a7406f2008a02962df1755766']->onRenderFilter($section, TRUE); //is the 'to' filter ?> <input type="hidden" name="option" value="com_cobalt"> <input type="hidden" name="view" value="records"> <input type="hidden" name="section_id" value="<?php echo $section->id;?>"> <input type="hidden" name="cat_id" value="<?php echo $cat_id;?>"> <input type="hidden" name="user_id" value="<?php echo ($user_id ? $user_id.':admin' : 0);?>"> <input type="hidden" name="view_what" value="<?php echo $vw;?>"> <input type="hidden" name="task" value="records.filters"> <input type="hidden" name="limitstart" value="0"> <div class="form-actions"> <button type="submit" class="btn btn-primary btn-large"> <?php echo JText::_('CSEARCH');?> </button> </div> </form>

Last Modified: 02 Mar 2014


Sergey
Total posts: 13,748
05 Jun 2013 09:06

I had fixed this error. Will work in next release tomorrow.

Suggestion better use

$filters[$keys_by_id[12]]->onRenderFilter($section, TRUE);

where 12 is an ID of the field rather than

$filters['kb3a66c2a7406f2008a02962df1755766']->onRenderFilter($section, TRUE);

And I am curios how did you so direction map in article full view? Did you use ->value property of the field?


Guest
05 Jun 2013 09:59

Sergey, that's so awesome! Thanks a million! I'm looking forward to it

And thanks for your suggestion about $keys_by_id, but somehow it didn't work for me, so, it tried this.

Furthermore to get a direction map I edited the com_cobalt/view/record/template, where I made a mysql call to the lattitude en longitude of the beginning and end point and plotted them on a map like this:

(thereby realising most of the time I suck at php, so there is probably a better way to make the mysql call, but he, it works nicely ; )


<?php $ritid = $item->id; $titlestad = mysqli_query($con,"SELECT * FROM WLHjm_js_res_record_values WHERE record_id=$ritid AND field_id='11' AND value_index='city'"); $titlestadrij = mysqli_fetch_array($titlestad); $stadvertrek = $titlestadrij['field_value']; $titlestadaankomst = mysqli_query($con,"SELECT * FROM WLHjm_js_res_record_values WHERE record_id=$ritid AND field_id='12' AND value_index='city'"); $titlestadaankomstrij = mysqli_fetch_array($titlestadaankomst); $stadaankomst = $titlestadaankomstrij['field_value']; $lataankomst = mysqli_query($con,"SELECT * FROM WLHjm_js_res_record_values WHERE record_id=$ritid AND field_id='12' AND value_index='lat'"); $lataankomstrij = mysqli_fetch_array($lataankomst); $lataankomst = $lataankomstrij['field_value']; $lonaankomst = mysqli_query($con,"SELECT * FROM WLHjm_js_res_record_values WHERE record_id=$ritid AND field_id='12' AND value_index='lng'"); $lonaankomstrij = mysqli_fetch_array($lonaankomst); $lonaankomst = $lonaankomstrij['field_value']; $latvertrek = mysqli_query($con,"SELECT * FROM WLHjm_js_res_record_values WHERE record_id=$ritid AND field_id='11' AND value_index='lat'"); $latvertrekrij = mysqli_fetch_array($latvertrek); $latvertrek = $latvertrekrij['field_value']; $lonvertrek = mysqli_query($con,"SELECT * FROM WLHjm_js_res_record_values WHERE record_id=$ritid AND field_id='11' AND value_index='lng'"); $lonvertrekrij = mysqli_fetch_array($lonvertrek); $lonvertrek = $lonvertrekrij['field_value']; echo '<br/>lataankomst: '; echo $lataankomst; echo '<br/>lonaankomst: '; echo $lonaankomst; echo '<br/>latvertrek: '; echo $latvertrek; echo '<br/>lonvertrek: '; echo $lonvertrek; ?>

AND


<script type="text/javascript" src="/ https://maps.googleapis.com/maps/api/js?key=AIzaSyAtsTloVY91R4NYLHTk2TeKdeTHDIkkCdU& ;sensor=false"> </script> <script type="text/javascript"> var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var map; //var vertrek = new google.maps.LatLng(37.7699298, -121.4469157); //var bestemming = new google.maps.LatLng(37.7683909618184, -122.51089453697205); var vertrek = new google.maps.LatLng("<?= $latvertrek ?>", "<?= $lonvertrek ?>"); var bestemming = new google.maps.LatLng("<?= $lataankomst ?>", "<?= $lonaankomst ?>"); function initialize() { directionsDisplay = new google.maps.DirectionsRenderer(); var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP, } var request = { origin: vertrek, destination: bestemming, travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); directionsDisplay.setMap(map); } google.maps.event.addDomListener(window, 'load', initialize); </script>

and


<div id="map-canvas"> </div>

Sergey
Total posts: 13,748
05 Jun 2013 11:05

This is how you can get needed values without SQL queries.

$latvertrek = $item->fields_by_id[12]->value['position']['lat'];

lonvertrek = $item->fields_by_id[12]->value['position']['lng'];

$lataankomst = $item->fields_by_id[14]->value['position']['lat'];

$lonaankomst = $item->fields_by_id[14]->value['position']['lng'];

Where 12 and 14 is an ID of the fields. I do not know if it is correct I have just typed any digits there.


Guest
12 Aug 2013 07:18

Hi Sergey,

Thanks to the cobalt component my website is almost finished ;)

The only major thing that's holding me back now are the cobalt maps filters who are still interfering.

In my search module I am using two gmaps filters, to filter for a 'from' and 'to'. If you only search using the 'from' field, everything is working fine, but if you are using the 'to' field, this value gets treated as if it where the 'from' field. ( and the value you'd set at the from field gets lost.)

You can check it out @ welovehitchhiking.com/index.php/home/hitchhiking.

Is there a hack I can use to get them both working as separate fields?

Thanks a lot, Alwin


I am using the default module template, and the deafault filter geo fields. updated on 2013/08/12th

Versions:

mod_cobalt_filters.j3.v.8.38

field_cobalt.j3.geo.v.8.146

pkg_cobalt.j3.everything.v.8.291

Hidden text


Sergey
Total posts: 13,748
12 Aug 2013 10:14

This is amazing work! I am really impressed how beautifully you have styles Cobalt.

I have fixed it and updated geo field on your site. It looks like it is working now.

PLease tell me, the Werhetket and Hichiken are also made with Cobalt or Joomla core content?


Guest
15 Aug 2013 13:54

It's amazing, works like a charm. How did you do it? Can I still opdate regular updates, or will that bring back the conflict?

Anyway, Thanks a million and we will reserve a special spot for you on the site once it is finished! Cheers to your health ;)


Sergey
Total posts: 13,748
16 Aug 2013 02:17

Can I still update regular updates, or will that bring back the conflict?

Yes you can update as usual.

Can I still update regular updates, or will that bring back the conflict?

Anyway, Thanks a million and we will reserve a special spot for you on the site once it is finished! Cheers to your health

You can write review on JED. That will help :)

Powered by Cobalt