• Resolved kyleform

    (@kyleform)


    Hey Johann

    Plugin works amazingly, great work on it!

    Was wondering if you can advise on a couple of things:

    1. I’m using a responsive bootstrap table and need to pull the header $th into the data title within the table body e.g. <td data-title=”$th”>$td</td>

    2. Is it possible to use this field within Flexible Content field?

    Hope you can help, much appreciated.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Johann Heyne

    (@jonua)

    Hi,

    1. The following code should do the trick with the data-title…

    $table = get_field( 'your_table_field_name' );
    
    if ( $table ) {
    
        echo '<table border="0">';
    
            if ( $table['header'] ) {
    
                echo '<thead>';
    
                    echo '<tr>';
    
                        foreach ( $table['header'] as $th ) {
    
                            echo '<th>';
                                echo $th['c'];
                            echo '</th>';
                        }
    
                    echo '</tr>';
    
                echo '</thead>';
            }
    
            echo '<tbody>';
    
                foreach ( $table['body'] as $tr ) {
    
                    echo '<tr>';
    
                        foreach ( $tr as $key => $td ) {
    
                            echo '<td data-title="' . $table['header'][ $key ]['c'] . '">';
                                echo $td['c'];
                            echo '</td>';
                        }
    
                    echo '</tr>';
                }
    
            echo '</tbody>';
    
        echo '</table>';
    }

    2. Yes, the table field should work in a Flexible Content field.

    Cheers,
    Johann

    Thread Starter kyleform

    (@kyleform)

    Hey Johann

    Thanks for the response, that worked perfectly, thanks very much for your help with that.

    I changed the get_field to get_sub_field hoping that would work, any ideas on what it should actually be?

    <?php if( get_row_layout() == ‘list’ ): ?>
    <?php
    $table = the_sub_field( ‘table’ );
    if ( $table ) {

    Plugin Author Johann Heyne

    (@jonua)

    $table = get_sub_field('table');

    Thread Starter kyleform

    (@kyleform)

    Thanks for responding again so quickly.

    The get_sub_field was correct, I just had the wrong field name for the row_layout.

    All working now, can finally allow clients to make CMS their own tables now, great plugin!!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Flexible Field & Responsive Table’ is closed to new replies.