Group Video Nested In A Group

Support MB Group Group Video Nested In A GroupResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38808
    Dan SmithDan Smith
    Participant

    group video nested in a group
    Using a code block I’m able to display a paragraph within a custom field group using this code.
    Group with ID: ‘ci_extra_content’ cloneable
    elements of that group
     radio button with iD: ci_content_radio
      radio button choices: none, image, paragraph
       cloneable WYSIWYG custom field with ID: ci_content_wysiwyg

      <?php $group_values = rwmb_meta( 'ci_extra_content' ); ?>
      <?php if ( ! empty( $group_values ) ) : ?>
        <?php foreach ( $group_values as $group_value ) : ?>
          <?php $selected = $group_value['ci_content_radio']; ?>
          <!-- Check if paragraph, WYSISYG selected -->
          <?php if ( $selected == 'paragraph' ) : ?>
            <?php echo '<div class="gallery-post__container width--full">'; ?>
            <?php $paragraphs = $group_value['ci_content_wysiwyg']; ?>
            <?php if ( ! empty( $paragraphs ) ) : ?>
              <?php foreach ( $paragraphs as $paragraph ) : ?>
                <?php echo $paragraph; ?>
              <?php endforeach ?>
            <?php endif ?>
            <?php echo '</div>'; ?>
          <?php endif ?>
        <?php endforeach ?>
      <?php endif ?>

    I’d like to add an option to the radio button of video but would like to use a nested group inside the first group with a custom fields for a display image, a url field to the actual video and some text that I’d use to explain what the video is about.

    Once I get to here:
    Group with ID: ‘ci_extra_content’
    elements of that group
     radio button with iD: ‘ci_content_radio’
      radio button choices: none, image, paragraph, video
     subgroup with ID: ‘ci_video_group’ cloneable
     elements of that group
       single image with ID: ‘ci_video_image’
       url with ID: ‘ci_video_url’
       text with ID: ‘ci_video_title’

      <?php $group_values = rwmb_meta( 'ci_extra_content' ); ?>
      <?php if ( ! empty( $group_values ) ) : ?>
        <?php foreach ( $group_values as $group_value ) : ?>
          <?php $selected = $group_value['ci_content_radio']; ?>
          <!-- Check if video selected -->
          <?php if ( $selected == 'video' ) : ?>

    was hoping you might be able to give me a hint on how to display the ‘ci_video_title’. If I can get that code I can probably figure out the rest.

          <?php endif ?>
        <?php endforeach ?>
      <?php endif ?>

    Any help with this would be greatly appreciated!

    #38820
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can just create a nested loop to display the video title in a subgroup like paragraphs, for example:

    $group_values = rwmb_meta( 'ci_extra_content' );
    foreach ( $group_values as $group_value ) {
    	$video_groups = $group_value['ci_video_group'];
    	foreach ( $video_groups as $video_group ) {
    		echo $video_group['ci_video_title'];
    	}
    }
    #38825
    Dan SmithDan Smith
    Participant

    thanks, got me close enough that I now have an idea about what I'm doing.

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