WordPress.org

Ready to get started?Download WordPress

Forums

WP-Table Reloaded
New feature suggest: auto numbering (4 posts)

  1. Yakir Gottesman
    Member
    Posted 2 years ago #

    Hi!

    Is it possible to add a feature of auto serial numbering for the rows? It should not include the header and footer.

    Please let me know.

    http://wordpress.org/extend/plugins/wp-table-reloaded/

  2. TobiasBg
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    thanks for the suggestion.

    Unfortunately, I'm not really sure how this could be implemented in a good way, especially with the user interface...

    For now, it might be the best idea to use the wp_table_reloaded_cell_content filter hook. That gives you access to the current row and column numbers, so that you could check if your are in the desired column (likely the first one), and then return the row number as the cell content.

    Regards,
    Tobias

  3. Yakir Gottesman
    Member
    Posted 2 years ago #

    Can you show me what you mean? I don't get it.

  4. TobiasBg
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    I mean a small Plugin Extension (see http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/extensions/ for an introduction), like this:

    add_filter( 'wp_table_reloaded_cell_content', 'wp_table_reloaded_first_column_auto_numbering', 10, 4 );
    function wp_table_reloaded_first_column_auto_numbering( $cell_content, $table_id, $row_number, $column_number ) {
    	if ( 123 != $table_id )
    		return $cell_content;
    	if ( 1 != $column_number )
    		return $cell_content;
    	if ( 1 == $row_number )
    		return $cell content;
    	// if we get here, we are in the table body, first column,
    	// so we print the row number, but -1, because of the header row
    	return ( $row_number - 1 );
    }

    The table ID needs to be changed of course, and if this is for more than one table, an in_array() check might be the easiest.
    Best wishes,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic