DBMaker

Simple Database Maker

 

What is this

WordPress plugin to create simple database from csv file.

How to get

Install plugin from wordpress.org 

Download from github

Screen shot

検索フォーム

 

Data list

Features

  • you can make database from csv file
  • import over 10000 records from csv file
  • delete all data records
  • support custom fields and taxonomies
  • sort and search data in backend
  • support shortcode for search form and result list in frontend
  • import from csv, insert only. update record not supported.

 

Usage

Create database

  1. Select DataBase Maker in admin menu. Add new post.
  2. Title is database name, it is displayed admin menu.
  3. Content is frontend search form. If content is empty, default form inserted.

 

Edit csv settings

settings for csv
  1. “post_type” is database type
  2. “format” is column names order in csv files. comma separated.see column names section
  3. “status” is default post status.
  4. “character encoding” is csv file’s encodeing
  5. “skip lines” : skip n lines
  6. “public access” is data status. if it is checked, public access from frontend.
  7. save post.

 

Import data from csv file

  1. Select your database name in admin menu.
  2. 「Select csv file and push “read csv”, start importing.
  3. Display progress bar, please wait for a while.

 

Data operation in admin menu

Example If custom field “dbm_search_form” is set 1, then load script.


add_filter('dbm_script_load_flag', 'my_search_form', 10, 1);
function my_search_form($flag) {
    global $post;
    if (isset($post->ID) && !$flag) {
        // Check dbm_search_form
        $meta = get_post_meta($post->ID, 'dbm_search_form', true);
        if ($meta == '1') {
            $flag = true;
        }
    }    
    return $flag;
}

 

Data list
  • keyword search target all columns
  • taxonomy filter supported
  • title, date and custom fields support sorting.
  • Delete all data supported
  • “View” is link to search form in frontend. 

Create search form for frontend

  1. Select DataBase Maker, edit database
  2. edit contents, see “Short codes” section
  3. save contents
  4. View posts

 

sample form

 

Column names

  • post_title: title: title of the post
  • post_author: (login or ID) The user name or user ID number
  • post_date: 
  • post_excerpt: 
  • post_status: 
  • post_name: slug
  • post_parent: 
  • menu_order: 
  • tax_{taxonomy}: (string, comma separated) Any field prefixed with tax_ will be used as a custom taxonomy.
  • {custom_field_key}: Any other column labels used as custom field.

 

Short codes

dbm_search

Create checkboxes for taxonomy

this short code is block type.

Parameters

  • post_type : required Search database post_type.
  • posts_per_page : default: 5
  • pager : set not empty string, pager support. default: ”(empty)
  • preload: set not empty string, data list display at initialize. default ”(empty)

Example

dbm_search post_type="database"
・・・
/dbm_search

 

dbm_tax_checkbox

Create checkboxes for taxonomy

Parameters

  • name : requried taxonomy name.(No “tax_” prefix)

Example

dbm_tax_checkbox name="postcode"

dbm_tax_select

Create select box for taxonomy.

Parameter

  • name : **requried** taxonomy name.(No “tax_” prefix)
  • multiple : multiple : This option set not empty string, multiple select box. default: ”
  • size : Select box size.

Example

dbm_tax_select name="postcode"

dbm_textbox

Create text input box

Parameter

  • name : Set search target column name. ‘s’ is target all columns. default : ‘s’
  • required : true or false. default : ‘false’

Example

dbm_textbox name="name" required="true"

dbm_result_table

Display search result table. This code need outside of dbm_search.

Parameter

  • label : required th tag names, comma separated.
  • data : required column names, comma separated. sync label order.

Example

dbm_result_table label="Name, Address" data="name,addrss"

dbm_result_pager

Output pager

Parameter

  • label : pager button label. default : ‘first, prev, next, last’

Example

dbm_result_pager label="First,prev,next,Last"

 

Hooks

 

dbm_script_load_flag

To use seach short code other page or post, enqueue script filter for ajax search script.

return true or false.

Parameter

  • $script_load :  load flag.

Example If custom field “dbm_search_form” is set 1, then load script.


add_filter('dbm_script_load_flag', 'my_search_form', 10, 1);
function my_search_form($flag) {
    global $post;
    if (isset($post->ID) && !$flag) {
        // Check dbm_search_form
        $meta = get_post_meta($post->ID, 'dbm_search_form', true);
        if ($meta == '1') {
            $flag = true;
        }
    }    
    return $flag;
}