Support

Account

Home Forums Add-ons Flexible Content Field How to get label for Reply To: How to get label for

  • Thank you for the reply and sorry for the delay in answering. Nevermind the properties (like key) of the layout object look different, the idea of looping through the subarray was indeed what did the trick. With help from a friend who’s a PHP veteran, the following loop gave the wanted values.

    To loop through all items at once:

    <?php
    foreach($content['layouts'] as $layout) {
        echo 'layout: ' . $layout['label'] . '<br>';
        foreach($layout['sub_fields'] as $subField) {
            echo 'field: ' . $subField['label'] . '<br>';
        }
    }
    ?>

    To put the item on the right spot, it’s necessary to point to the right index-number of the subarray.
    So for example (using the loop from the question), this worked for Highlights with index 1:

    <?php elseif(get_row_layout() == "highlights"): ?>	
    <?php echo $content['layouts'][1]['sub_fields'][0]['label']; //highlights ?>