Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Возводим динамическую таблицу:
No views, no problem
Michael Krainiuk
Michael Krainiuk
Drupal Senior Developer
Мой опыт в Drupal разработке
●  Разработка
●  Управление проектами
●  Drupal ауди...
Вывод
Вывод
Вывод
Что делать?
Views
Views
Views
Или
Или
DB -> Page
DB -> Page
DB -> Page
Page
hook_menu() {
$items[‘admin/dashboard/testing’] = array(
‘page callback’ => ‘my_site_testing’,
…,
);
return $items;
}
/**	
	*	Page	callback	for	admin/dashboard/testing.	
	*/	
function	my_site_testing()	{		
		drupal_set_title('Nodes');	
	
		...
/**	
	*	Page	callback	for	admin/dashboard/testing.	
	*/	
function	my_site_testing()	{		
		drupal_set_title('Nodes');	
	
		...
/**	
	*	Page	callback	for	admin/dashboard/testing.	
	*/	
function	my_site_testing()	{		
		drupal_set_title('Nodes');	
	
		...
/**	
	*	Page	callback	for	admin/dashboard/testing.	
	*/	
function	my_site_testing()	{		
		drupal_set_title('Nodes');	
	
		...
/**	
	*	Page	callback	for	admin/dashboard/testing.	
	*/	
function	my_site_testing()	{		
		drupal_set_title('Nodes');	
	
		...
Header
$head	=	array(	
				'ID',	
				'Title',	
				'User',	
				'UID',	
		);
Header
$head	=	array(	
		array('data'	=>	'ID',	'field'	=>	'n.nid'),	
		array('data'	=>	'Title'),	
		array('data'	=>	'User'...
Header
$head	=	array(	
		array('data'	=>	'ID',	'field'	=>	'n.nid'),	
		array('data'	=>	'Title'),	
		array('data'	=>	'User'...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Table
10 строк
А где?
Rows
$query	=	db_select('node',	'n’);	
$query->fields('n',	array('nid',	'title'));	
$query->fields('u',	array('name',	'uid...
Rows
$query	=	db_select('node',	'n')->extend('PagerDefault')->extend('TableSort');	
$query->fields('n',	array('nid',	'titl...
Rows
$query	=	db_select('node',	'n')->extend('PagerDefault')->extend('TableSort');	
$query->fields('n',	array('nid',	'titl...
Rows
$query	=	db_select('node',	'n')->extend('PagerDefault')->extend('TableSort');	
$query->fields('n',	array('nid',	'titl...
Результат
Результат
Результат
Michael Krainiuk
Drupal Senior Developer
kraynuk.m@i20.biz
При поддержке:
Организаторы:
Thank you!
возводим динамическую таблицу, No views, no problem. Крайнюк Михаил
возводим динамическую таблицу, No views, no problem. Крайнюк Михаил
Upcoming SlideShare
Loading in …5
×

возводим динамическую таблицу, No views, no problem. Крайнюк Михаил

113 views

Published on

Крайнюк Михаил выступил с темой “Возводим динамическую таблицу: No views, no problems”на Drupal Cafe #18

Видео с презентации вы сможете увидеть, перейдя по ссылке https://youtu.be/RLSWPOS67RE?list=PLtUZRIj1OWYzCGb3OCYMVYqnrJ-EpH0Ot

Published in: Internet
  • Be the first to comment

  • Be the first to like this

возводим динамическую таблицу, No views, no problem. Крайнюк Михаил

  1. 1. Возводим динамическую таблицу: No views, no problem Michael Krainiuk
  2. 2. Michael Krainiuk Drupal Senior Developer Мой опыт в Drupal разработке ●  Разработка ●  Управление проектами ●  Drupal аудит ●  Консультация ●  Локализация Drupal ●  Разработка Drupal модулей
  3. 3. Вывод
  4. 4. Вывод
  5. 5. Вывод
  6. 6. Что делать?
  7. 7. Views
  8. 8. Views
  9. 9. Views
  10. 10. Или
  11. 11. Или
  12. 12. DB -> Page
  13. 13. DB -> Page
  14. 14. DB -> Page
  15. 15. Page hook_menu() { $items[‘admin/dashboard/testing’] = array( ‘page callback’ => ‘my_site_testing’, …, ); return $items; }
  16. 16. /** * Page callback for admin/dashboard/testing. */ function my_site_testing() { drupal_set_title('Nodes'); $head = array( 'ID', 'Title', 'User', 'UID', ); $rows = array( array(5, ‘First’, ‘John’, 10), ); $tab['table'] = array( '#theme' => 'table', '#header' => $head, '#rows' => $rows, '#empty' => 'No data available.', ); $tab['table_pager'] = array('#theme' => 'pager'); return drupal_render($tab); }
  17. 17. /** * Page callback for admin/dashboard/testing. */ function my_site_testing() { drupal_set_title('Nodes'); $head = array( 'ID', 'Title', 'User', 'UID', ); $rows = array( array(5, ‘First’, ‘John’, 10), ); $tab['table'] = array( '#theme' => 'table', '#header' => $head, '#rows' => $rows, '#empty' => 'No data available.', ); $tab['table_pager'] = array('#theme' => 'pager'); return drupal_render($tab); }
  18. 18. /** * Page callback for admin/dashboard/testing. */ function my_site_testing() { drupal_set_title('Nodes'); $head = array( 'ID', 'Title', 'User', 'UID', ); $rows = array( array(5, ‘First’, ‘John’, 10), ); $tab['table'] = array( '#theme' => 'table', '#header' => $head, '#rows' => $rows, '#empty' => 'No data available.', ); $tab['table_pager'] = array('#theme' => 'pager'); return drupal_render($tab); }
  19. 19. /** * Page callback for admin/dashboard/testing. */ function my_site_testing() { drupal_set_title('Nodes'); $head = array( 'ID', 'Title', 'User', 'UID', ); $rows = array( array(5, ‘First’, ‘John’, 10), ); $tab['table'] = array( '#theme' => 'table', '#header' => $head, '#rows' => $rows, '#empty' => 'No data available.', ); $tab['table_pager'] = array('#theme' => 'pager'); return drupal_render($tab); }
  20. 20. /** * Page callback for admin/dashboard/testing. */ function my_site_testing() { drupal_set_title('Nodes'); $head = array( 'ID', 'Title', 'User', 'UID', ); $rows = array( array(5, ‘First’, ‘John’, 10), ); $tab['table'] = array( '#theme' => 'table', '#header' => $head, '#rows' => $rows, '#empty' => 'No data available.', ); $tab['table_pager'] = array('#theme' => 'pager'); return drupal_render($tab); }
  21. 21. Header $head = array( 'ID', 'Title', 'User', 'UID', );
  22. 22. Header $head = array( array('data' => 'ID', 'field' => 'n.nid'), array('data' => 'Title'), array('data' => 'User'), array('data' => 'UID', 'field' => 'u.uid'), ); $head = array( 'ID', 'Title', 'User', 'UID', );
  23. 23. Header $head = array( array('data' => 'ID', 'field' => 'n.nid'), array('data' => 'Title'), array('data' => 'User'), array('data' => 'UID', 'field' => 'u.uid'), ); $head = array( 'ID', 'Title', 'User', 'UID', );
  24. 24. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); }
  25. 25. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); }
  26. 26. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); } 1 1
  27. 27. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); } 1 1 2 2
  28. 28. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); } 1 1 2 2 3 3
  29. 29. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); } 1 1 2 2 3 3 4 4
  30. 30. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); }
  31. 31. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); }
  32. 32. Table 10 строк
  33. 33. А где?
  34. 34. Rows $query = db_select('node', 'n’); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); }
  35. 35. Rows $query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort'); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); }
  36. 36. Rows $query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort'); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->orderByHeader($head) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); }
  37. 37. Rows $query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort'); $query->fields('n', array('nid', 'title')); $query->fields('u', array('name', 'uid')); $query->leftJoin('users', 'u', 'u.uid = n.uid'); $query->condition('u.uid', 0, '<>'); $result = $query ->limit(10) ->orderByHeader($head) ->execute(); foreach ($result as $row) { $rows[] = array( 'data' => array( $row->nid, $row->title, $row->name, $row->uid, ), ); } $head = array( array('data' => 'ID', 'field' => 'n.nid'), array('data' => 'Title'), array('data' => 'User'), array('data' => 'UID', 'field' => 'u.uid'), );
  38. 38. Результат
  39. 39. Результат
  40. 40. Результат
  41. 41. Michael Krainiuk Drupal Senior Developer kraynuk.m@i20.biz При поддержке: Организаторы: Thank you!

×