/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), 'join' => array( // Join with node table 'node' => array( 'left_field' => 'title', 'field' => 'category', ) ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'desc' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
// custom_tableのjoin結果(Viewsの検索SQL) SELECT custom_table.id AS custom_table_id, custom_table.category AS custom_table_category, custom_table.desc AS custom_table_desc, node.created AS node_created FROM {node} node LEFT JOIN {custom_table} custom_table ON node.title = custom_table.category WHERE node.status = '1' AND (node.type IN ('article')) AND (node.title LIKE 'cate-a' ) ORDER BY node_created DESC LIMIT 10 OFFSET 0
添付 | サイズ |
---|---|
custom_table.zip (1.51 KB) | 1.51 KB |
/** * Implements hook_views_api(). */ function custom_table_views_api() { return array( 'api' => 3, ); } /** * Implements hook_views_data_alter(). */ function custom_table_views_data_alter(&$data) { $d = $data; // nodeタイプの"title"にリレーションシップ関連をつける $data['node']['title']['relationship'] = array( 'handler' => 'views_handler_relationship', 'base' => 'custom_table', 'title' => 'Custom Table Category', 'base field' => 'category', ); } /** * Implements hook_views_data(). */ function custom_table_views_data() { $table = array( 'custom_table' => array( 'table' => array( 'group' => 'custom_table', 'base' => array( 'field' => 'id', //Primary key 'title' => t('Test Data ID'), 'help' => t('The Id for the test data'), ), ), 'id' => array( 'title' => t('Custom Table ID'), 'help' => t('Test data Id field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_numeric' ), 'sort' => array('handler' => 'views_handler_sort'), ), 'category' => array( 'title' => t('Category'), 'help' => t('The category that refer to node'), 'field' => array('click sortable' => TRUE, ), 'filter' => array('handler' => 'views_handler_filter_string' ), 'sort' => array( 'handler' => 'views_handler_sort' ), ), 'description' => array( 'title' => t('Description'), 'help' => t('Test data description field'), 'field' => array('click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_string' ), 'sort' => array('handler' => 'views_handler_sort' ), ), ) ); return $table; }
/** * Implements hook_views_data_alter(). */ function drills_ch_vocabulary_views_data_alter(&$data) { // ダミーフィールド(Description)をViewsに追加 $data['drills_ch_vocabulary']['description'] = array( 'title' => t('Description'), 'help' => t('Description depend on selected language'), 'field' => array( 'handler' => 'field_handler_description', 'click sortable' => FALSE, ), ); } // サイト言語より説明フィールドを選択し、クエリにセット class field_handler_description extends views_handler_field{ Function query() { $this->ensure_my_table(); $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); // サイトの言語検出 global $language; if( $language->language == 'en' ){ // 英語の場合 $field_name = "en_desc" ; } else if( $language->language == 'ja' ){ // 日本語の場合 $field_name = "ja_desc"; } else { $field_name = "ch_desc" ; // 中国語の場合 } // 取得したフィールド名をクエリにセット $this->field_alias = $this->query->add_field($this->table_alias, $field_name, NULL, $params); $this->add_additional_fields(); } }
/** * Implements hook_views_api(). */ function YOUR_MODULE_NAME_views_api() { return array( 'api' => 3, 'path' => drupal_get_path('module', 'YOUR_MODULE_NAME') . '/views', ); } /** * Implements hook_views_data_alter(). */ function YOUR_MODULE_NAME_views_data_alter(&$data) { $d = $data; $data['ch_vocabulary']['add_to_my_vocabulary'] = array( 'title' => t('Add to My Vocabulary'), 'help' => t('Add this vocabulary to My Vocabulary'), 'field' => array( 'handler' => 'add_vocabulary_to_my_vocabulary_handler', ), ); } /** * チェックボックス作成用のハンドル */ class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … // ajaxの処理 ), ); return render($form) ; } }
class add_vocabulary_to_my_vocabulary_handler extends views_handler_field{ function query() { // 何もないで、このフィールドをクエリに加えない } function render($value){ $form['add_to_my_vocabulary'] = array( '#type' => 'checkbox', '#title' => 'Add', '#ajax' => array( 'callback' => 'add_to_my_vocabulary', 'effect' => 'fade', … ), ); return render($form) ; } }