Custom Fields
Re-Envisioned
Support Meta Box Group Subfields not displaying within Oxygen Custom Field/Meta Options

  • Creator
    Topic
  • #27838

    Hello,

    I created a group field with two sub-fields (rec_url & where_to_buy). These do not show up within the Custom Field/Meta Options within Oxygen Builder (see here).

    How can I insert these sub-fields? I do not know PHP, so I will likely need more detailed instructions if adding PHP will be necessary.

    Thank you!

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

    Hi,

    Please follow the documentation to know how to get the subfield's value https://docs.metabox.io/extensions/meta-box-group/#getting-sub-field-values.

    and refer to your topic to run the PHP function with Oxygen https://metabox.io/support/topic/output-shortcode-from-a-custom-field/.

    You should have the basic knowledge of coding about PHP, HTML, CSS to do some advanced cases.

    #27865

    Thank you for the links.

    I feel competent with html and css - not at all with php. Will php be necessary to be able to use the full functionality of Meta Box even when/if Meta Box integrates with Oxygen?

    Can you tell please me where I would input the following (snippet code or code block)?
    (It's a cloneable group)

    $group_value = rwmb_meta( 'group_id' );
    
    array(
        'sub_field_1_key' => 'sub_field_1_value',
        'sub_field_2_key' => 'sub_field_2_value',
        'sub_field_3_key' => 'sub_field_3_value',
        //...
    )
    
    $value = isset( $group_value[$sub_field_key] ) ? $group_value[$sub_field_key] : '';
    echo $value; // Display sub-field value
    
    array(
        array(
            'sub_field_1_key' => 'sub_field_1_value',
            'sub_field_2_key' => 'sub_field_2_value',
            'sub_field_3_key' => 'sub_field_3_value',
            //...
        ),
        array(
            'sub_field_1_key' => 'sub_field_1_value',
            'sub_field_2_key' => 'sub_field_2_value',
            'sub_field_3_key' => 'sub_field_3_value',
            //...
        ),
        //...
    )
    
    $group_values = rwmb_meta( 'group_id' );
    if ( ! empty( $group_values ) ) {
        foreach ( $group_values as $group_value ) {
            $value = isset( $group_value[$sub_field_key] ) ? $group_value[$sub_field_key] : '';
            echo $value; // Display sub-field value
        }
    }
    
    #28112

    Hi again - can you please respond to my last message?

    #28119
    Long Nguyen
    Moderator

    Hi Amanda,

    Sorry for the late reply.

    You can use the PHP code anytime even the integration released. It can help you to do some advanced cases when the integration won't cover.

    I recommend using the Code Snippets to run the custom function.

    function my_custom_function() {
        $contacts = rwmb_meta( 'contacts' );
        if ( ! empty( $contacts ) ) {
            foreach ( $contacts as $contact ) {
                echo '<div class="contact">';
                echo '<h4>', 'Contact info', '</h4>';
                echo '<p><label>', 'Name:', '<label> ', $contact['name'], '</p>';
                echo '<p><label>', 'Email:', '<label> ', $contact['email'], '</p>';
                echo '<p><label>', 'Phone number:', '<label> ', $contact['phone'], '</p>';
                echo '</div>';
            }
        }
    }

    See the example for the cloneable group https://docs.metabox.io/extensions/meta-box-group/#examples

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