Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author ka2

    (@ka2)

    Hi there, thank you for your inquiry.

    It’s really too bad, but your both hopes is not possible in the current plugin.

    However, I also would like to support advanced data retrieval as query of “JOIN” in the future. I was surprised to your fantastic idea of including the custom button to the data rows. Its your idea will be stock for additional future functionality.

    Thank you,

    Thread Starter San Zamoyski

    (@san-zamoyski)

    Hi!

    Thank You for Your fast response.
    I’ve been wondering if i can use mysql VIEWs for joining tables – as a workaround.

    Is there any way to fast modify plugin to add some buttons? Buttons can be hardcoded. I’m just asking WHERE i should add something.

    Best regards!

    Plugin Author ka2

    (@ka2)

    Hmmm,

    If you can hardcoded into the sources of the plugin, you may try to embed directly button into the file of the following.

    – This contents is rendered by shortcode
    templates/cdbt-public-edit.php : 269 to 273 lines

    – This contents is rendered on admin panel
    templates/cdbt-edit.php : 216 to 220 lines

    The event of clicking on the button add as JavaScript in the “lib/cdbt.scripts.php”. In this way, you can add the processing and yourself button that you want.

    Thread Starter San Zamoyski

    (@san-zamoyski)

    Unlucky hardcoded buttons won’t work for me…

    Been wondering if it is possible to add plus/minus buttons in edition-table for increase/decrease some int values.

    I’ll soon test VIEWS and tell if it works.

    How to show table with mysql WHERE clause?

    Sorry for multiple questions, but this plugin is almost everything what i need.

    Thread Starter San Zamoyski

    (@san-zamoyski)

    Unfotunetly i am unable to ‘import’ mysql VIEW…

    Plugin Author ka2

    (@ka2)

    I try to include my original button to rendered page by a shortcode of [cdbt-view].

    For example if table is as follows:

    CREATE TABLE wp_int_test (
      ID int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
      col int(11) NOT NULL,
      created datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'created datetime',
      updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'updated datetime',
      PRIMARY KEY (ID)
    ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

    The html contents in body of post is follows:

    [cdbt-view table="wp_int_test" display_search="false" display_list_num="false" enable_sort="false" exclude_cols="created"]
    
    <script>
    function refresh_page() {
      location.reload();
    }
    </script>

    In the “templates/cdbt-public-list.php” on the directory of cdbt plugin, I have customized as follows:

    # 189 to 190 lines
      $output = apply_filters('cdbt_view_column_value', $val, $table_name, $key);
      $list_rows .= '<td>'. $output .'</td>';

    Then, In the “functions.php” of using theme, I have added as follows:

    add_filter('cdbt_view_column_value', 'add_my_button', 10, 4);
    function add_my_button($val, $table_name, $column_name, $id) {
      if ($table_name == 'wp_int_test' && $column_name == 'col') {
        $increase_query = sprintf('UPDATE %s SET %s = %d WHERE ID = %d', $table_name, $column_name, intval($val)+1, intval($id));
        $increase_button = do_shortcode(sprintf('[cdbt-submit table="%s" label="%s" query="%s" final="refresh_page" add_class="%s"]', $table_name, '+', $increase_query, 'default btn-xs'));
    
        $decrease_query = sprintf('UPDATE %s SET %s = %d WHERE ID = %d', $table_name, $column_name, intval($val)-1, intval($id));
        $decrease_button = do_shortcode(sprintf('[cdbt-submit table="%s" label="%s" query="%s" final="refresh_page" add_class="%s"]', $table_name, '-', $decrease_query, 'default btn-xs align-left'));
    
        $val = sprintf('%s <p class="pull-right">%s%s</p>', $val, $increase_button, $decrease_button);
      }
      return $val;
    }

    By the above as, you can make a list of pages that you can change the value by added buttons of “+” or “-” to the particular column.

    Screenshot image of the sample is here.

    Plugin Author ka2

    (@ka2)

    And, This is reply to one more question.

    How to show table with mysql WHERE clause?

    If you want to narrow the record that you want to display in the Where clause, please use the short code of [cdbt-extract].

    Thank you,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can i add custom button to ALL rows?’ is closed to new replies.