Forum Replies Created

Viewing 15 replies - 91 through 105 (of 274 total)
  • Plugin Author ka2

    (@ka2)

    Plugin Author ka2

    (@ka2)

    Thank you for reply.

    I will examine that problem.

    Plugin Author ka2

    (@ka2)

    Okay, I should be thanking you.

    Because I was recently also published the specifications of the filter hooks, it was a good experience to be able to introduce the mechanism of per that.

    Plugin Author ka2

    (@ka2)

    Does columns from “col2” to “col6” that are specified in the “order_cols” exist in the table?

    I have tried at the following table:

    CREATE TABLE database_table (
      ID bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
      LastName varchar(100) DEFAULT NULL,
      FirstName varchar(100) DEFAULT NULL,
      col1 varchar(100) DEFAULT NULL,
      col2 varchar(100) DEFAULT NULL,
      col3 varchar(100) DEFAULT NULL,
      col4 varchar(100) DEFAULT NULL,
      col5 varchar(100) DEFAULT NULL,
      col6 varchar(100) DEFAULT NULL,
      col7 varchar(100) DEFAULT 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=2 DEFAULT CHARSET=utf8mb4

    Shortcode is as follows:

    [cdbt-view table="database_table" bootstrap_style="true" enable_repeater="true" display_list_num="false" display_search="true" display_title="true" enable_sort="true" display_index_row="true" order_cols="col2,col3,col4,col5,col6" sort_order="LastName:asc,FirstName:asc" limit_items="0" truncate_strings="0" image_render="responsive" display_filter="false" display_view="false" thumbnail_width="100" ajax_load="false"]

    I has been successfully displayed in the above test.

    Thank you,

    Plugin Author ka2

    (@ka2)

    Thank you for your inquiry.

    Yes, you can add the custom fields and customize the process at the time of updating data. I will introduce the sample code as an example below.

    Sample table:

    CREATE TABLE wp_products (
      ProductID bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Product ID',
      ProductName varchar(200) NOT NULL,
      Quantity int(11) unsigned NOT NULL DEFAULT '0',
      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 (ProductID)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

    Sample Post:

    [cdbt-edit table="wp_products"]

    Filter hooks: (“functios.php” in theme)

    function add_custom_field_wp_products( $elements_options, $shortcode_name, $table ){
      if ( is_null( get_post() ) && 'cdbt-entry' === $shortcode_name && 'wp_products' === $table ) {
        $elements_options[] = [
          'elementName' => 'ChangeQuantity',
          'elementLabel' => 'Addition/Subtraction',
          'elementType' => 'number',
          'isRequired' => false,
          'defaultValue' => 0,
          'placeholder' => 'Enter changing quantity',
          'addClass' => '',
          'selectableList' => '',
          'horizontalList' => false,
          'elementSize' => 2,
          'helperText' => '',
          'elementExtras' => []
        ];
        $element_order = [0,1,3,2];
        array_multisort( $element_order, $elements_options );
      }
      return $elements_options;
    }
    add_filter( 'cdbt_shortcode_custom_forms', 'add_custom_field_wp_products', 10, 3 );
    
    function custom_update_wp_products( $data, $table_name, $data_field_format ){
      if ( ! is_admin() && 'wp_products' === $table_name && isset( $_POST['custom-database-tables']['ChangeQuantity'] ) ) {
        if ( intval( $_POST['custom-database-tables']['ChangeQuantity'] ) !== 0 ) {
          $data['Quantity'] += intval( $_POST['custom-database-tables']['ChangeQuantity'] );
        }
      }
      return $data;
    }
    add_filter( 'cdbt_before_update_data', 'custom_update_wp_products', 10, 3 );

    By the above code, you can have the additional field for addition or subtraction and custom update process. I have uploaded the demo page of this sample, please try to see.

    Please refer below full description for each filters (sorry in Japanese only).

    https://ka2.org/cdbt/v2/filter-reference/cdbt_shortcode_custom_forms/
    https://ka2.org/cdbt/v2/filter-reference/cdbt_before_update_data/

    Thank you,

    Plugin Author ka2

    (@ka2)

    Thank you for your inquiry.

    I describes the shortcode options “Exclude Columns”, “Display Columns”, and “Column Order”. Since the function of these three options overlap, we have established a priority.

    “Column Order” > “Display Columns” > “Exclude Columns” as priority order

    If the value is set to “Column Order”, the setting of “Display Columns” and “Exclude Columns” will be ignored.

    This specification is intended to to have a short code and compatibility that was created in version 1.x of the plugin. I’m sorry for confusing you.

    Also, as you say, matter of “Enable Switching View” is a bug. I’m going to fix at the next version.

    Finally, it is a matter to get an error of “headers already sent”. Because at the outputting of shortcode in CDBT plugin is necessary to once buffering as processing, it seems the impact has gone out. Consider whether there is a workaround.

    Thank you,

    Plugin Author ka2

    (@ka2)

    Thank you very much for reporting.

    Please tell me the string of datetime format that you have changed.

    Currently, I was knowing that there is a problem with the process of converting the datetime format, then I’m fixing that bug. At the same time I want to respond to be able to resolve your trouble.

    Thank you,

    Plugin Author ka2

    (@ka2)

    I will fixed a bug in the javascript for convert of date format.
    I’m going to release as such hotfix at the next version.

    Sorry, please wait for while.

    Plugin Author ka2

    (@ka2)

    Was examined, it seems there is a problem with the Chrome browser(version 49.x) side.

    https://bugs.chromium.org/p/chromium/issues/detail?id=581925

    Please update chrome browser (to version 50.0.x).

    Plugin Author ka2

    (@ka2)

    Thank you very much for reporting.

    Sorry, there was a trouble on the converting of “F” as date format.
    I will release a modified version in the next version.

    Sorry, please wait for a while.

    Plugin Author ka2

    (@ka2)

    Sorry for my late reply.

    You need to be careful about the uppercase/lowercase of alphabet of the column named as aliased. At the property values of the column definition, you must be the same of aliased the column name.

    $_overwrite_sql = <<<SQL
    SELECT count(id) AS BETS,
      Sum(IF(win_loss = 'win', 1, 0)) AS Wins,
      Sum(IF(win_loss = 'loss', 1, 0)) AS Looses,
      Sum(IF(win_loss = 'void', 1, 0)) AS Void
    FROM %s;
    SQL;
      $sql = sprintf( $_overwrite_sql, $table_name );
    $columns[] = [
        'label' => 'BETS', // Actual displayed strings
        'property' => 'BETS', // Alias column name
        ...
      $columns[] = [
        'label' => 'Wins',
        'property' => 'Wins',
        ...

    Please try again with reference to the above code.

    Thank you,

    Plugin Author ka2

    (@ka2)

    In the source that you added in “functions.php” has mistake.

    Your source:

    if ( get_post()->ID === (ID) && 'cdbt-view' === $shortcode_name && 'bc_tips' === $table )

    Correct source:

    if ( 'cdbt-view' === $shortcode_name && 'bc_tips' === $table )

    Please try it.

    Plugin Author ka2

    (@ka2)

    Sorry, description of sample code was leaking.

    if ( get_post()->ID === {Displayed Post ID} && 'cdbt-view' === $shortcode_name && 'bc_tips' === $table ) {

    You should convert to post id of page that you put shortcode from the “{Displayed post ID}” in the above part of code. Or, at the “get_post()->ID === {Displayed Post ID} &&” please remove.

    Thank you,

    Plugin Author ka2

    (@ka2)

    Yes, you can.

    If your “BC_TIPS” table is already created, you can manage the data from the WordPress administration screen by importing the table to this plugin.

    If you want to display the table on the home page can be displayed in the following shortcode:

    [cdbt-view table="bc_tips" order_cols="date,time,league,match,tip,odds,book,win_loss"]

    If you want to output by the short code via query of select statement used an alias, please use the filter as follows:

    shortcode:

    [cdbt-view table="bc_tips" order_cols="ID"]

    filterhooks(in “functions.php of your theme”):

    function bc_tips_get_data_sql( $sql, $table_name, $sql_clauses ) {
      if ( get_post()->ID === {Displayed Post ID} && 'bc_tips' === $table_name ) {
        $_overwrite_sql = <<<SQL
    SELECT count(ID) AS bets,count(win_loss) AS win
    FROM %s
    WHERE win_loss = 'yes'
    SQL;
    
    $sql = sprintf( $_overwrite_sql, $table_name );
      }
      return $sql;
    }
    add_filter( 'cdbt_crud_get_data_sql', 'bc_tips_get_data_sql', 10, 3 );
    
    function bc_tips_shortcode_custom_columns( $columns, $shortcode_name, $table ){
      if ( get_post()->ID === {Displayed Post ID} && 'cdbt-view' === $shortcode_name && 'bc_tips' === $table ) {
        $columns = [];
        $columns[] = [
          'label' => 'Bets',
          'property' => 'bets',
          'sortable' => false,
          'sortDirection' => 'asc',
          'dataNumric' => true,
          'truncateStrings' => '0',
          'className' => '',
        ];
        $columns[] = [
          'label' => 'WIN',
          'property' => 'win',
          'sortable' => false,
          'sortDirection' => 'asc',
          'dataNumric' => true,
          'truncateStrings' => '0',
          'className' => '',
        ];
      }
      return $columns;
    }
    add_filter( 'cdbt_shortcode_custom_columns', 'bc_tips_shortcode_custom_columns', 10, 3 );

    Please try it.

    Thank you,

    Plugin Author ka2

    (@ka2)

    Thank you for your inquiry.

    In the current plugin, the uploading of image files are supported only column of blob type. You will be able to upload common image file if the column type is the size of “mediumblob” or “longblob”.

    For example, the SQL for adding a column of blob type to an existing table is as follows.

    ALTER TABLE {YourTableName} ADD {NewColumnName} longblob comment 'Image File' AFTER {BeforeColumnName};

    You can column added by submitting the above SQL at the “Modify Table” of the table management.

    Note: the uploaded image file to blob type column will be stored directly as binary data in the table of database. Therefore future scaling taking into the storage size of the database must also be considered.

    Thank you,

Viewing 15 replies - 91 through 105 (of 274 total)