Семинар-практикум по drupal
TRANSCRIPT
- CMS Drupal
CMS Drupal .
.
CMS.
.
.
:
CMS
.
.
, , .
: ,
*
:
ID
Title
Author
Post date
Change date
Content
Page
ID
Title
Author
Post date
Change date
Teaser
Content
News
ID
Title
Author
Post date
Change date
Content
Page
ID
Page_ID
Author
Post date
Change date
Content
Comment
ID
Content_ID
Parent_ID
Type
Author
Post date
Change date
Content
Comments
ID
Content_ID
Type
Author
Post date
Change date
Content
Comment
ID
Title
Author
Post date
Change date
Node
NID
Teaser
Content
News
ID
Content_ID
Author
Post date
Change date
Content
Comment
NID
Content
Page
ID
Content_ID
Parent_ID
Type
Author
Post date
Change date
Content
Comments
CMS Drupal
Drupal PHP
PHP-
,
CMS Drupal
// function my_module_menu() { $items = array(); $items['form'] = array( 'title' => t('Form'), 'page callback' => 'drupal_get_form', 'page arguments' => array('first_form'), 'type' => MENU_NORMAL_ITEM, ); return $items;}// function first_form($form_state) { $form['name'] = array( '#type' => 'textfield', '#title' => t('Name'), ); return $form;}// function first_form_validate($form, &$form_state) {if(!mb_strlen($form_state['values']['name']))form_set_error('name', t('Enter a Name.')); }// function first_form_submit($form, &$form_state){drupal_set_message(t('The form has been submitted.'));}
AHAH
CMS Drupal
function myahah_menu() {$items['myahah'] = array('title' => 'AHAH!', 'page callback' => 'drupal_get_form','page arguments' => array('poof_form'), 'access callback' => TRUE,); $items['myahah/message_js'] = array('page callback' => 'myahah_message_js', 'type' => MENU_CALLBACK,'access callback' => TRUE,);return $items;}function myahah_form(){$form['target'] = array('#type' => 'markup','#value' => ''.t('click here').'',);$form['submit'] = array('#type' => 'submit','#value' => t('click me'),'#ahah' => array('event' => 'click','path' => 'myahah/message_js','wrapper' => 'target','effect' => 'fade',));return $form;}function myahah_message_js(){return drupal_json(array('status' => TRUE, 'data' => t('TRUE!')));}
CMS Drupal
// $header = array('Col1', 'Col2');// $rows = array( array('Cell1', 'Cell2'), array('Cell3', 'Cell4'),);print theme('table', $header, $rows);Col1Col2
Cell1Cell2
Cell3Cell4
CMS Drupal
$rows = array(); // $header = array( array('data' => 'ID', 'field' => 'nid'), array('data' => '', 'field' => 'type'), array('data' => '', 'field' => 'title'),); $result = db_query(("SELECT nid, type, title FROM {node} WHERE status = 1" . tablesort_sql($header));
// while ($row = db_fetch_array($result)){ $rows[] = $row; } print theme('table', $header, $rows);
Schema API
$schema['node'] = array( // 'fields' => array( 'nid' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE ), 'vid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0 ), 'type' => array( 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '' ), 'title' => array( 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '' ), ),// 'primary key' => array( 'nid' ),// 'unique keys' => array( 'vid' => array( 'vid' ) ),// 'indexes' => array( 'nid' => array( 'nid' ), 'node_title_type' => array( 'title', array( 'type', 4 ) ), ),); 'node'
PHPTemplate
, PHP, ( , PHP)
PHPTemplate