Custom Fields
Re-Envisioned
Support MB Custom Table Date, media and repeater sections

  • Creator
    Topic
  • #32141
    Resolved Torsten Gauger
    Participant

    Hello,

    I set up a .php for MB custom Table. The post information is generated using forms in Elementor with e-addons. As beginner, I do not understand all necessary steps. Maybe you have a tip on the following questions:

      1. I have a date field inside my posts. Can you check beneath code if I set it correctly or should I use a different type?
      1. I have repeater fields in my posts. To your recommendation, I tried to only use the subfields and not the whole group. Can you check the below code, if it is correct? (You can see all repeaters bearing the name "repeater" in beneath code)
      1. I do not know how to set the link to a media file (One of the post metas is a video/image) Can you help me find the correct code? (Very bottom of the code)
    register_activation_hook( <strong>FILE</strong>, 'prefix_create_table' );
    function prefix_create_table() {
        if ( ! class_exists( 'MB_Custom_Table_API' ) ) {
            return;
        }
        MB_Custom_Table_API::create( 'my_custom_table', array(
            'story_basic_category' => 'TEXT NOT NULL',
            'story_basic_category_date'   => 'VARCHAR(20) NOT NULL',
            'story_basic_category_experience'   => 'TEXT NOT NULL',
            'story_basic_question'   => 'TEXT NOT NULL',
            'story_basic_category_target_group'   => 'TEXT NOT NULL',
            'story_basic_repeater_paragraph_heading'   => 'TEXT NOT NULL',
            'story_basic_repeater_paragraph_text'   => 'TEXT NOT NULL',
            'story_basic_repeater_paragraph_media'   => 'TEXT NOT NULL',
        );
    }
    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
            'title'        => 'Meta Box Title',
            'storage_type' => 'custom_table',    // Important
            'table'        => 'my_custom_table', // Your custom table name
            'fields'       => array(
                array(
                    'id'   => 'story_basic_category',
                    'type' => 'text',
                    'name' => 'Story Basic Category',
                ),
                array(
                    'id'   => 'story_basic_category_date',
                    'type' => 'date',
                    'name' => 'Story Basic Category Date',
                ),
                array(
                    'id'   => 'story_basic_category_experience',
                    'type' => 'text',
                    'name' => 'Story Basic Category Experience',
                ),
                array(
                    'id'   => 'story_basic_question',
                    'type' => 'text',
                    'name' => 'Story Basic Question',
                ),
                array(
                    'id'   => 'story_basic_category_target_group',
                    'type' => 'text',
                    'name' => 'Story Basic Category Target Group',
                ),
                array(
                    'id'   => 'story_basic_repeater_paragraph_heading',
                    'type' => 'text',
                    'name' => 'Story Basic Repeater Paragraph Heading',
                ),
                array(
                    'id'   => 'story_basic_repeater_paragraph_text',
                    'type' => 'text',
                    'name' => 'Story Basic Repeater Paragraph Text',
                ),
                array(
                    'id'   => 'story_basic_repeater_paragraph_media',
                    'type' => 'file',
                    'name' => 'Story Basic Repeater Paragraph Media',
                ),
            ),
        );
        return $meta_boxes;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.