Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #27804
    Long Nguyen
    Moderator

    Hi Zenjukai,

    Thank you for reaching out.

    I've tested the dateFormat setting again and see it displays on the frontend as the format on the backend. Can you please share the code that creates the custom field and show it on the frontend?

    You can use the option Get PHP Code in the Builder to generate the code https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code

    #27807
    zenjukai@gmail.com
    Participant

    Hello Long,

    Thank you for your reply. Here is the generated PHP code. I am using Oxygen and Script Organizer, so I took the generated code and then created a script to run, as I don't have a functions.php file. The format still doesn't change. Any thought?

    <?php
    add_filter( 'rwmb_meta_boxes', 'rswp_oxygen_dateFormat_events' );
    
    function rswp_oxygen_dateFormat_events( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Event Details', 'rswp_oxygen' ),
            'id'         => 'event-details',
            'post_types' => ['event'],
            'context'    => 'after_title',
            'fields'     => [
                [
                    'name'       => __( 'Event Details', 'rswp_oxygen' ),
                    'id'         => $prefix . 'event_details',
                    'type'       => 'textarea',
                    'rows'       => 6,
                    'required'   => 1,
                    'save_field' => 1,
                ],
                [
                    'name'       => __( 'Event Date', 'rswp_oxygen' ),
                    'id'         => $prefix . 'event_date',
                    'type'       => 'date',
                    'required'   => 1,
                    'js_options' => [
                        'dateFormat' => 'd-MM-yy',
                    ],
                    'save_field' => 1,
                ],
                [
                    'name'       => __( 'Event Time', 'rswp_oxygen' ),
                    'id'         => $prefix . 'event_time',
                    'type'       => 'time',
                    'required'   => 1,
                    'save_field' => 1,
                ],
                [
                    'name'       => __( 'Event Location', 'rswp_oxygen' ),
                    'id'         => $prefix . 'event_location',
                    'type'       => 'textarea',
                    'required'   => 1,
                    'save_field' => 1,
                ],
            ],
        ];
    
        return $meta_boxes;
    }

    Sorry, I am new at this, so still a bit of a learning curve. Thanks again for your help.

    Cheers

    #27810
    zenjukai@gmail.com
    Participant

    Also Long, just as an FYI. I have tried the same output on a theme based site that used "Views" instead on injecting the code and all works great.

    So I am wondering if it has to do with the setup or the execution with Oxygen?

    Cheers

    #27811
    zenjukai@gmail.com
    Participant

    Hey Long,

    Me again ... so never mind with the issue above. What I am seeing is the error is not coming from me or the plugin, but rather how Oxygen renders the custom variables. Yes it can probably work somehow, but it seems kind of pointless to make a hack for a simple process.

    I love metabox ... it is an amazing plugin that makes life so much easier, so to just hack it for a simple function doesn't make sense.

    So I am just going to move away from Oxygen and just use Views with Twig! =)

    Cheers and thanks again for your time and effort.

    #27820
    Long Nguyen
    Moderator

    Let me know if you have any questions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.