Group or not?

Support General Group or not?Resolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #31111
    info@ceescoenen.nl[email protected]
    Participant

    I make a portfolio website with all my projects. With Custom Fields I fill all my project fields. I will make a group with tasks in a project

    #1 : website development : a lot of text
    #2 : photography : a lot of text
    #3 : SEO : a lot of text

    Do I make a group in the custom fields, make this group-field clonebale and the add three different subfields to the group?

    #31112
    Long NguyenLong Nguyen
    Moderator

    Hi Cees,

    Do you need to add more #1, #2, #3 items? If yes, you can create 3 cloneable fields textarea or wysiwyg.

    If not, just create 3 fields textarea or wysiwyg. It is based on your requirements.

    #31113
    info@ceescoenen.nl[email protected]
    Participant

    Hi,

    Yes I need sometimes one, sometimes three etc. But each clonable row has three or four fields:
    - taskname
    - task-number
    - tasktext

    I is true that I have to use a group for this?

    #31118
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I think creating a cloneable group is a good way. You can add more tasks with a set of tasks for each row.

    #31121
    info@ceescoenen.nl[email protected]
    Participant

    It won't display at the front-end. What is wrong? I have a group_id pj_taken and two subfields pj_taak and pj_taak_text. I also don't understand the ??'' in the code sample from your website.

    $group = rwmb_meta( 'pj_taken' );
    if ( empty( $group ) ) {
    }
    
    $output = '';
    
    // Sub-field title.
    $title = $group['pj_taak'] ?? '';
    $output .= '<h3 class="my-title">' . $title . '</h3>';
    
    
    // Sub-field description.
    $desc = $group['pj_taak_text'] ?? '';
    $output .= '<div class="my-description">' . wpautop( $desc ). '</div>';
    echo $output;
    

    ?>

    #31123
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If it's the cloneable group, you need to use a loop to iterate through group elements. For example:

    $group_values = rwmb_meta( 'pj_taken' );
    if ( ! empty( $group_values ) ) {
        foreach ( $group_values as $group_value ) {
            $value = isset( $group_value['pj_taak'] ) ? $group_value['pj_taak'] : '';
            echo $value; // Display sub-field value
        }
    }

    Get more details on the documentation https://docs.metabox.io/extensions/meta-box-group/#getting-sub-field-values

    #31124
    info@ceescoenen.nl[email protected]
    Participant

    Hi Long,

    Sorry.. it gives a Eval()'d code error and I can't figure out why.

    #31125
    info@ceescoenen.nl[email protected]
    Participant

    Found!! Missing one } 🙂

    Sorry.

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