Support

Account

Home Forums Add-ons Flexible Content Field Check if two row layouts are used

Helping

Check if two row layouts are used

  • I’m building a site with a number of flexible fields to create a page builder.

    One one page I’m hoping to group two fields into one container row if they both exist.

    So I’m looking for a way to check if two row layouts exist and when they do to load them with a div surrounding them.

    I have been testing with:

    if (get_row_layout() == "property_specs" &&get_row_layout() == "property_overview") {
    if (get_row_layout() == "property_overview"):
                    echo '<div class="container">';
                    include get_template_directory() .
                        "/includes/overview.php";
                elseif (get_row_layout() == "property_specs"):
                    include get_template_directory() .
                        "/includes/specs.php";
                    echo "</div>";
                endif;
            }

    But the initial ‘if’ statement itself just isn’t coming up as a positive.
    Is there another way to check if two row layouts exist on the page, and then if so, can I call them as I have above?

  • The value stored in the database for a flex field is an array. The array contains a list, in order of the layouts that exist in the flex field. You can get this by using get_post_meta()

    
    $layouts = get_post_mata($post->ID, 'flex_field_name', true);
    if (is_array($layouts) && 
        in_array('property_specs', $layouts) && 
        in_array('property_overview', $layouts)) {
      // both exist
    }
    

    that will tell you if both exist, but not tell you if one follows the other.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.