Forum Replies Created

Viewing 15 replies - 31 through 45 (of 386 total)
  • Plugin Author Johann Heyne

    (@jonua)

    I have also sent a suggestion to the “Resizable Editor Sidebar” plugin development team on how to fix this unnecessary behavior of their script.

    Plugin Author Johann Heyne

    (@jonua)

    Thanks for the research. Yes, there is an issue with the “Resizable Editor Sidebar” plugin script. The “Resizable Editor Sidebar” plugin script fires every 500 milliseconds a jQuery UI resizable() at the sidebar element causing a mutation event every 500 milliseconds. That prevents the mutation observer threshold of the table field plugin of 500 milliseconds. I will reduce the table field mutation threshold number to fix that issue in the next plugin version.

    Thanks,
    Johann

    Plugin Author Johann Heyne

    (@jonua)

    This means that the column information in the table data is may incorrect or missing. Can you please send me the output of get_field( 'your_broken_table_field_name', $post_id, false ); ? This allows me to see exactly what went wrong with the table data.

    Thanks!

    Plugin Author Johann Heyne

    (@jonua)

    Hi,

    I integrated a table auto repair in the next unpublished version of the plugin (v1.3.25).
    You can pre testing it, if that version helps to fix the table issue.

    Downloadlink v1.3.25:
    https://downloads.wordpress.org/plugin/advanced-custom-fields-table-field.1.3.25.zip

    On loading the page, the table with the protruding cells should be displayed repaired. The repaired table will only be permanently repaired when the page/content is saved. The contents of the protruding cells will be lost.

    Cheers,
    Johann

    Plugin Author Johann Heyne

    (@jonua)

    Hi,

    thanks for reporting me that issue.

    The t.ui_event_ajax(); was replaced by a mutation observer to detect new tables in different situations and locations. For some reason this doesn’t seem to work in your situation. Can you help me clarify the circumstances?

    I would like to ask:

    • Which browser and version are you using?
    • Does the problem also occur in another browser?
    • Which operating system and version are you using?
    • Can you provide me the acf_register_block_type() parameters for your use?
    • Are there JavaScript errors in the console and can you provide them if relevant?

    Thanks a lot,
    Johann

    Plugin Author Johann Heyne

    (@jonua)

    Hi,

    for some reason the table data seems to be corrupted or there is a new browser version in which the script no longer works correctly. It would help if you could describe to me what happened before the error.

    Try to fix the problem step by step:

    • reload the page
    • delete all broken lines and re-enter them
    • delete the last correct line and try to create a new one
    • delete all lines and enter new ones
    • delete all columns and enter new columns and rows
    • delete the Gutenberg block and enter a new one

    If none of this helps, I need more information to reproduce the problem.

    • Which Browser name and version the issue appears?
    • Does the issue appears on other browsers?
    • Which Operating system was used?
    • Which location is the table field applied to?
    • Is it applied to a page using the Gutenberg editor?

    Thanks much for reporting me that issue and helping me to resolve this,
    Johann

    Plugin Author Johann Heyne

    (@jonua)

    You can do this in your table output PHP code.
    https://wordpress.org/plugins/advanced-custom-fields-table-field/#how%20to%20output%20the%20table%20html%3F

    Here is an example, that adds a link to the first cell of the first table body row:

    $table = get_field( 'your_table_field_name' );

    if ( ! empty ( $table ) ) {

    echo '<table border="0">';

    if ( ! empty( $table['caption'] ) ) {

    echo '<caption>' . $table['caption'] . '</caption>';
    }

    if ( ! empty( $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 $row_index => $tr ) {

    echo '<tr>';

    foreach ( $tr as $cell_index => $td ) {

    echo '<td>';

    if ( $row_index === 0 && $cell_index === 0 ) {
    $td['c'] .= '<a href="#my-link">a link in the first cell of the first table body row</a>';
    }

    echo $td['c'];
    echo '</td>';
    }

    echo '</tr>';
    }

    echo '</tbody>';

    echo '</table>';
    }
    Plugin Author Johann Heyne

    (@jonua)

    I thought it might be helpful to differentiate between the following two scenarios:

    If the table has only one empty cell, then get_field() returns FALSEget_field() returns NULL when a field is not stored in the database. That happens when a page is copied but not their fields content. You can check both with empty()

    $table = get_field( 'your_table_field_name' );
    
    if ( ! empty( $table ) ) {
        // $table is not FALSE and not NULL.
        // Field exists in database and has content.
    }

    Is this inconsistency compared to other fields a problem?

    See docs

    Plugin Author Johann Heyne

    (@jonua)

    Thanks! You’re right. The plugin returns false if there is no table entry. I overlooked this setting up the Rest-API schema and fixed it with the 1.3.24 version. The Rest-API should still return false on empty table.

    • This reply was modified 1 year, 11 months ago by Johann Heyne.
    Plugin Author Johann Heyne

    (@jonua)

    Hi,

    the last version of the plugin 1.3.23 should fix the REST-API error “string,null“.

    For updating the table object via REST-API you first should get the unformatted table data.

    In PHP you have to set the 3 parameter of get_field() to false.
    $unformatted_table_data = get_field( 'fieldname', $post_id, false);

    In JavaScript you can get the unformatted table data by the REST-API.

    Then you can modify the table data object and update the field by the REST-API.

    The unformatted table object of a field named “table” of an REST-API GET should look like this example:

    {
    "acf": {
    "table": {
    "acftf": {
    "v": "1.3.21"
    },
    "p": {
    "o": {
    "uh": 1
    },
    "ca": "Table caption content"
    },
    "c": [
    {
    "p": ""
    },
    {
    "p": ""
    }
    ],
    "h": [
    {
    "c": "Header, first cell content"
    },
    {
    "c": "Header, second cell content"
    }
    ],
    "b": [
    [
    {
    "c": "Body Row 1, first cell content"
    },
    {
    "c": "Body Row 1, second cell content"
    }
    ],
    [
    {
    "c": "Body Row 2, first cell content"
    },
    {
    "c": "Body Row 2, second cell content"
    }
    ]
    ]
    }
    }
    }

    acf.table.p This object contains table parameters.
    acf.table.p.o This object contains table options.
    acf.table.p.o.uh Determines whether a header should be used or not.
    acf.table.p.ca The content of the table caption.

    acf.table.c Array of table columns. Amount should always be the same as in the table header or body row arrays. This columns array was intended to hold columns parameters.
    acf.table.c[0].p First column, still unused parameter property.

    acf.table.h Array of the table header cells.
    acf.table.h[0].c Content of the first header cell.

    acf.table.b Array of the table body rows.
    acf.table.b[0] Array of the cells of the table body first row.
    acf.table.b[0][0].c Content of the cell of the table body first cell in first row.

    I hope this helps.
    Cheers, Johann

    • This reply was modified 1 year, 11 months ago by Johann Heyne.
    • This reply was modified 1 year, 11 months ago by Johann Heyne.
    Plugin Author Johann Heyne

    (@jonua)

    Hi,

    The ACF shortcode [acf field="table"] does not work with the table field. ACF only tries here to output the Array data from the table field, which ends in an error.

    In order to have a shortcode to output an HTML table based on the data in the table field, you have to define your own shorcode. At the following link you will find instructions (copy & paste) on how to setup and use the shortcode.

    https://wordpress.org/plugins/advanced-custom-fields-table-field/#how%20to%20use%20the%20table%20field%20in%20elementor%20page%20builder%3F

    Cheers,
    Johann

    • This reply was modified 2 years, 1 month ago by Johann Heyne.
    Plugin Author Johann Heyne

    (@jonua)

    For table subfields of an field type group, you must update the shortcode hook in the functions with the following:

    function shortcode_acf_tablefield( $atts ) {
    
        $a = shortcode_atts( array(
            'table-class' => '',
            'field-name' => false, // use a slash "/" to separate group field name and table subfield name
            'post-id' => false,
        ), $atts );
    
        // Return if no field name is given
        if ( ! is_string( $a['field-name'] ) ) {
            
            return '';
        }
    
        // May gets sub fields names
        $field_names = explode( '/', $a['field-name'] );
    
        // Gets the root fields value
        $table = get_field( $field_names[0], $a['post-id'] );
    
        // May gets a table subfields value
        foreach ( $field_names as $key => $name ) {
    
            if ( 0 < $key ) {
    
                $table = $table[ $name ];
            }
        }
    
        $return = '';
    
        if ( $table ) {
    
            $return .= '<table class="' . $a['table-class'] . '" border="0">';
    
                if ( ! empty( $table['caption'] ) ) {
    
                    echo '<caption>' . $table['caption'] . '</caption>';
                }
    
                if ( $table['header'] ) {
    
                    $return .= '<thead>';
    
                        $return .= '<tr>';
    
                            foreach ( $table['header'] as $th ) {
    
                                $return .= '<th>';
                                    $return .= $th['c'];
                                $return .= '</th>';
                            }
    
                        $return .= '</tr>';
    
                    $return .= '</thead>';
                }
    
                $return .= '<tbody>';
    
                    foreach ( $table['body'] as $tr ) {
    
                        $return .= '<tr>';
    
                            foreach ( $tr as $td ) {
    
                                $return .= '<td>';
                                    $return .= $td['c'];
                                $return .= '</td>';
                            }
    
                        $return .= '</tr>';
                    }
    
                $return .= '</tbody>';
    
            $return .= '</table>';
        }
    
        return $return;
    }
    
    add_shortcode( 'tablefield', 'shortcode_acf_tablefield' );

    Than you can define the group field name and the table subfield name separated by a slash in the shortcode:

    [tablefield  field-name="group-field-name/table-subfield-name"]
    Plugin Author Johann Heyne

    (@jonua)

    Thanks, that helped. Your table field is a subfield of another field. Perhaps a repeater field or a group field. Thats why the shortcode wont work. Which type of field ist the parent field? Maybe I can send another updated shortcode.

    Plugin Author Johann Heyne

    (@jonua)

    Here are a few questions that might narrow down the problem.

    Is the table preview on the elementor editing page?
    Ist the table field on a page or an option page or somewhere else?
    Is the correct table field name given in the shortcode?
    Is the correct post-id given in the shortcode?
    Has the table more than one cell or at least one cell with content in it?

    Any context helps.

    Plugin Author Johann Heyne

    (@jonua)

    My test was successful. Therefore, there must be something not quite right with your integration. Please check the quotes in the shortcode

    [tablefield field-name="your table field name"]

    are ” not “. This is a common source of errors. Also check, if the Shortcode hook is really integrated somehow by functions.php.

    Cheers, Johann

Viewing 15 replies - 31 through 45 (of 386 total)