Distance
This topic contains 1 reply, has 2 voices, and was last updated by Alex Rollin 7 years, 3 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
November 26, 2017 at 9:14 pm #406863
Hello,
There is some possibility of putting a name in front of (see photo). If I say it’s a train station called “Santa Eugenia”. I put the name. Some help?Thanks
Distance to custom field
https://wpgeodirectory.com/distance-custom-field/// agrega el campo personalizado a la lista de campos personalizados
función geodir_custom_field_distance_to ( $ custom_fields , $ post_type ) {
$ custom_fields [ ‘ distance_to ‘ ] = array ( // El valor de la clave debe ser único y no contener espacios.
‘ field_type ‘ => ‘ text ‘ , //
‘ clase ‘ => ‘ gd-distance-to ‘ ,
‘ icono ‘ => ‘ fa fa-map-marcador ‘ ,
‘ name ‘ => __ ( ‘ Distance To ‘ , ‘ geodirectory ‘ ),
‘ description ‘ => __ ( ‘ Agrega una entrada para coordenadas de GPS que luego generará la distancia de lugar a ese punto. ‘ , ‘ geodirectory ‘ ),
‘ defaults ‘ => array (
‘ data_type ‘ => ‘ VARCHAR ‘ ,
‘ admin_title ‘ => ‘ Distancia a ‘ ,
‘ site_title ‘ => ‘ Distancia a ‘ ,
‘ admin_desc ‘ => ‘ Ingrese las coordenadas de GPS como53.347302, -6.258953
‘ ,
‘ htmlvar_name ‘ => ‘ distanceto ‘ ,
‘ is_active ‘ => true ,
‘ for_admin_use ‘ => falso ,
‘ default_value ‘ => ‘ ‘ ,
‘ show_in ‘ => ‘ [detalle], [listado] ‘ ,
‘ is_required ‘ => falso ,
‘ validation_pattern ‘ => ‘ (-? \ d {1,3} \. \ d +), (-? \ d {1,3} \. \ d +) ‘ ,
‘ validation_msg ‘ => ‘ Por favor ingrese coordenadas GPS válidas. ‘ ,
‘ required_msg ‘ => ‘ ‘ ,
‘ field_icon ‘ => ‘ fa fa-map-marker ‘ ,
‘ css_class ‘ => ‘ ‘ ,
‘ cat_sort ‘ => falso
)
);
devuelve $ custom_fields ;
}
// ‘geodir_custom_fields_custom’ se agregará al cuadro de campos personalizados, ‘geodir_custom_fields_predefined’ se agregará a la caja predefinida
add_filter ( ‘ geodir_custom_fields_custom ‘ , ‘ geodir_custom_field_distance_to ‘ , 10 , 2 );
// crea el resultado para el campo personalizado
función geodir_custom_field_output_distance_to ( $ html , $ location , $ cf ) {
global $ post ;
if ( isset ( $ post -> { $ cf [ ‘ htmlvar_name ‘ ]}) && $ post -> { $ cf [ ‘ htmlvar_name ‘ ]} ! = ‘ ‘ ):
$ html_var = $ cf [ ‘ htmlvar_name ‘ ];
$ start_arr = explode ( ‘ , ‘ , $ post -> { $ cf [ ‘ htmlvar_name ‘ ]});
$ startPoint = array ( ‘ latitude ‘ => trim ( $ start_arr [ 0 ]), ‘ longitude ‘ => trim ( $ start_arr [ 1 ]));
$ endLat = $ post -> post_latitude ;
$ endLon = $ post -> post_longitude ;
$ endPoint = array ( ‘ latitud ‘ => $ endLat , ‘ longitud ‘ => $ endLon );
$ uom = get_option ( ‘ geodir_search_dist_1 ‘ );
$ distance = geodir_calculateDistanceFromLatLong ( $ startPoint , $ endPoint , $ uom );
if ( round ( $ distance , 2 ) == 0 ) {
$ uom = get_option ( ‘ geodir_search_dist_2 ‘ );
$ distance = geodir_calculateDistanceFromLatLong ( $ startPoint , $ endPoint , $ uom );
if ( $ uom == ‘ pies ‘ ) {
$ uom = __ ( ‘ pies ‘ , ‘ geodirectory ‘ );
} else {
$ uom = __ ( ‘ metros ‘ , ‘ geodirectory ‘ );
}
$ distancia = ronda ( $ distancia ) . ‘ ‘ . $ uom ;
} else {
if ( $ uom == ‘ millas ‘ ) {
$ uom = __ ( ‘ millas ‘ , ‘ geodirectory ‘ );
} else {
$ uom = __ ( ‘ km ‘ , ‘ geodirectory ‘ );
}
$ distancia = ronda ( $ distancia , 2 ) . ‘ ‘ . $ uom ;
}
$ class = ( $ cf [ ‘ htmlvar_name ‘ ] == ‘ geodir_timing ‘ )? ” geodir-i-time ” : ” geodir-i-text ” ;
$ field_icon = geodir_field_icon_proccess ( $ cf );
if ( strpos ( $ field_icon , ‘ http ‘ ) ! == falso ) {
$ field_icon_af = ‘ ‘ ;
} elseif ( $ field_icon == ‘ ‘ ) {
$ field_icon_af = ( $ cf [ ‘ htmlvar_name ‘ ] == ‘ geodir_timing ‘ )? ‘ <i class = “fa fa-reloj-o”> </ i> ‘ : ” ” ;
} else {
$ field_icon_af = $ field_icon ;
$ field_icon = ‘ ‘ ;
}
$ html = ‘ <div class = “geodir_more_info ‘ . $ cf [ ‘ css_class ‘ ] . ‘ ‘ . $ html_var . ‘ ” style = “clear: both;”> <span class = “geodir-i-taxonomy geodir-i -category “style =” ‘ . $ field_icon . ‘ “> ‘ . $ field_icon_af ;
$ html . = ( trim ( $ cf [ ‘ site_title ‘ ]))? __ ( $ cf [ ‘ site_title ‘ ], ‘ geodirectory ‘ ) . ‘ : ‘ : ‘ ‘ ;
$ html . = ‘ </ span> ‘ . $ distancia . ‘ </ div> ‘ ;
endif ;
devolver $ html ;
}
add_filter ( ‘ geodir_custom_field_output_key_key_distance_to ‘ , ‘ geodir_custom_field_output_distance_to ‘ , 10 , 3 );November 27, 2017 at 5:58 am #406897Hello!
Per this article, you can create a different field for “Distance to Airport” or “Distance to Train Station”. The demo field is recommended for use in a single city or region where all the locations would be shown with a “Distance to” a single airport or train station, and you would set the same value for the LatLon for each listing.
https://wpgeodirectory.com/distance-custom-field/
To change it to “Distance to Train Station” adjust line 9
'site_title' => 'Distance to train station',
This code in the article is provided as an example.
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket