Support Forum » User Profile

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Binding street, city etc from adress field not working #24431

    Thank you very much. I got it running and tested it a little bit. In your example it is not extracting the city. The key that worked for me is "administrative_area_level_1". Also worth mentioning is the fact, that my mistake was to add prefixes to my column ids.

    I think I also found a bug by extracting the steet information:

    
     [
        'type'          => 'text',
        'name'          => 'Street',
        'id'            => 'street_address',
        'address_field' => 'address6',
    ],
    [
        'type'          => 'text',
        'name'          => 'Number',
        'id'            => 'street_number',
        'address_field' => 'address6',
    ],
    

    The Number is working but not the street name. Cant find the Street in any other field.

    And finally I got an example with open street map because the binding is working different. If someone need this information. I think the documentation could be more detailed. In this example all bindings are working:

    array(
        'id'            => 'address',
        'name'          => 'Search Pin',
        'desc'          => 'Search order: number, street, city, postcode',
        'type'          => 'text',
    ),
    array(
        'id'            => 'map',
        'name'          => 'Map', 
        'type'          => 'osm',
        'language'      => 'de',
        'address_field' => 'address',
    ),
    array(
        'id'            => 'road',
        'name'          => 'Street',
        'type'          => 'text',
        'address_field' => 'address',
        'binding'       => 'road',
    ),
    array(
        'id'            => 'house_number',
        'name'          => 'Number',
        'type'          => 'text',
        'address_field' => 'address',
        'binding'       => 'house_number',
    ),
    array(
        'id'            => 'postcode',
        'name'          => 'Postcode',
        'type'          => 'text',
        'address_field' => 'address',
        'binding'       => 'postcode',
    ),
    array(
        'id'            => 'city',
        'name'          => 'City',
        'type'          => 'text',
        'address_field' => 'address',
        'binding'       => 'city',
    ),
    array(
        'id'            => 'country',
        'name'          => 'Country',
        'type'          => 'text',
        'address_field' => 'address',
        'binding'       => 'country',
    ),
    in reply to: Date formatting #15545

    Found a solution for merging my date and time field to one. This could help you:
    functions.php

    
    add_action( 'admin_init', 'prefix_add_custom_columns', 20 );
    function prefix_add_custom_columns() {
        require_once get_stylesheet_directory() . '/my_theme/divi/Prefix_Custom_Admin_Columns.php';
        new Prefix_Custom_Admin_Columns( 'my_cpt', array() );
    }
    

    The Class:

    
    class Prefix_Custom_Admin_Columns extends MB_Admin_Columns_Post {
        public function columns( $columns ) {
            $columns  = parent::columns( $columns );
            $this->add( $columns, 'cpt_start', 'Start', 'before', 'date' );
            return $columns;
        }
        public function show( $column, $post_id ) {
            $value = rwmb_the_value( $column, '', $post_id, false );
    
            switch ( $column ) {
                case 'cpt_start':
                    $value = date( 'd.m.Y', strtotime( $value ) );
                    if( $value == '01.01.1970' ) {
                        echo '-/-';
                    } else {
                        echo $value;
                    }
                    $value = rwmb_the_value( 'cpt_start_time', '', $post_id, false  );
                    if( $value != '' && !is_null( $value ) ){
                        echo ' ( '.$value.' )';
                    }
                    break;
            }
        }
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)