Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. /**¬
  2.  * Implements hook_block_view().¬
  3.  */¬
  4. function hello_world_block_view($delta = '') {¬
  5. $block = array();¬
  6. ▸ ▸ switch($delta) {¬
  7. ▸ ▸ ▸ case 'hello_world';¬
  8. ▸ ▸ ▸ ▸ ▸ $links_query =·¬
  9. ▸ ▸ ▸ ▸ ▸ ▸ "select node.title as node_title, node.nid as nid¬
  10. ▸ ▸ ▸ ▸ ▸ ▸ from {node} node¬
  11. ▸ ▸ ▸ ▸ ▸ ▸ left join (select td.*, tn.nid AS nid¬
  12. ▸ ▸ ▸ ▸ ▸ ▸ from {taxonomy_term_data} td¬
  13. ▸ ▸ ▸ ▸ ▸ ▸ left join {taxonomy_vocabulary} tv on td.vid = tv.vid¬
  14. ▸ ▸ ▸ ▸ ▸ ▸ left join {taxonomy_index} tn on tn.tid = td.tid¬
  15. ▸ ▸ ▸ ▸ ▸ ▸ where  (tv.machine_name in  ('sections')) ) taxonomy_term_data_node ON node.nid = taxonomy_term_data_node.nid¬
  16. ▸ ▸ ▸ ▸ ▸ ▸ inner join {field_data_field_enabled} taxonomy_term_data_node__field_data_field_enabled on taxonomy_term_data_node.tid = taxonomy_term_data_node__field_data_field_enabled.entity_id and (taxonomy_term_data_node__field_data_field_enabled.entity_type = 'taxonomy_term' and taxonomy_term_data_node__field_data_field_enabled.deleted = '0')¬
  17. ▸ ▸ ▸ ▸ ▸ ▸ where (( (node.status = '1') and (node.type in  ('hello_world_article')) AND (taxonomy_term_data_node__field_data_field_enabled.field_enabled_value = '1') ))";¬
  18. ▸ ▸ ▸ ▸ ▸ $links_query_results = db_query($links_query);¬
  19. ▸ ▸ ▸ ▸ ▸ ▸ if ($links_query_results) {¬
  20. ▸ ▸ ▸ ▸ ▸ ▸ ▸ dpm($links_query_results);¬
  21. ▸ ▸ ▸ ▸ ▸ ▸ ▸ while ($row = $links_query_results->fetchAssoc()) {¬
  22. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ dpm($row);¬
  23. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ $row->node_title = l($row->node_title, "node/$row->nid");¬
  24. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ $rows[] = $row;¬
  25. ▸ ▸ ▸ ▸ ▸ ▸ ▸ }¬
  26. ▸ ▸ ▸ ▸ ▸ ▸ }¬
  27. ▸ ▸ ▸ ▸ ▸ ▸ $variables = array();¬
  28. ▸ ▸ ▸ ▸ ▸ ▸ $block['subject'] = t('Hello World!');¬
  29. ▸ ▸ ▸ ▸ ▸ ▸ $block['content'] = theme('table', array(¬
  30.   ▸ ▸ ▸ ▸ ▸ ▸ 'header' => $header,¬
  31.   ▸ ▸ ▸ ▸ ▸ ▸ 'rows' => $options,¬
  32.   ▸ ▸ ▸ ▸ ▸ ▸ 'attributes' => array('class' => array('mytable'))¬
  33. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ));¬
  34. ▸ ▸ ▸ ▸ ▸ ▸ ▸ dpm($block['content']);¬
  35. ▸ ▸ ▸ break;¬
  36. ▸ ▸ ▸ ▸ }¬
  37. return $block;¬
  38. ▸ ▸ }¬
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement