Hello everyone :)...I'm new to this amazing program and i'm trying to implement it on my server.Thanks in advance to people who read this and sorry for my bad english 😉
I'm trying to find a way to store geolocalization variables (lat and long) in osclass database.
I want to store lat and long in database table oc_t_item_location in which two geolocalization fields (d_coord lat and d_coord long) are already placed (maybe for geoloc plugins). So i was trying to create a plugin for this. Any suggestion would be appreciated. Thanks a lot!*
You want to save coordinates in the two columns (d_coord lat & d_coord long)?
Where you get the values for them? When do you want to save them?
Available for custom Osclass development. www.defected.dev
Hello, thank you for reply!
I want to add coordinates of every item in the item-post form. Here my code:
function initAutocomplete() {
var address = 'address';
$(document).ready(function () {
var autocomplete;
autocomplete = new google.maps.places.Autocomplete(document.getElementById(address), {
types: ['address'],
});
autocomplete.setFields(['address_component', 'geometry']);
autocomplete.addListener('place_changed', geolocate);
function geolocate(){
var place = autocomplete.getPlace();
lat = place.geometry.location.lat(),
long = place.geometry.location.lng();
-------------
(item-post.php)
<div class="control-group">
<label class="control-label" for="lat"><?php _e('lat', 'bender'); ?></label>
<div class="controls">
<input id="lat" type="hidden" name="lat" value="lat" />
It works (i checked POST data with chrome). But don't save in database (still returns NULL in d_coord_lat). I don't know how to use ajax here (i guess..).
you need to use item_post hook to save in to database. but I don't know how exactly.
find out the hooks here https://market.osclasscommunity.com/docs/hooks
[member=184]Paolo[/member] You are a bit lucky in this case because Osclass already checks for lat & long fields on item post and saves them if they are present.
Just rename your hidden input names to d_coord_lat & d_coord_long.
Available for custom Osclass development. www.defected.dev
Hey! thanks for reply! Unfortunately I can't make it works. Here my code:
(in item-post)
<div class="control-group">
<label class="control-label" for="d_coord_lat"><?php _e('d_coord_lat', 'bender'); ?></label>
<div class="controls">
<input id="d_coord_lat" type="hidden" name="d_coord_lat" value="12.34567890" />
</div>
This is just a test...I can see 12.34567890 in google chrome POST data sent to index.php, but on mariadb d_coord_lat is still NULL.