Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 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. ▸ ▸ ▸ ▸ ▸ ▸ ▸ $block_content = '';¬
  22. ▸ ▸ ▸ ▸ ▸ ▸ ▸ while ($row = $links_query_results->fetchAssoc()) {¬
  23. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ $block_content .= '<div class="hello_world_link">';¬
  24. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ $block_content .= l($row['node_title'], 'node/'.$row['nid']);¬
  25. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ $block_content .= '</div>';¬
  26. ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ $rows[] = $row;¬
  27. ▸ ▸ ▸ ▸ ▸ ▸ ▸ }¬
  28. ▸ ▸ ▸ ▸ ▸ ▸ }¬
  29. ▸ ▸ ▸ ▸ ▸ ▸ $variables = array();¬
  30. ▸ ▸ ▸ ▸ ▸ ▸ $block['subject'] = t('Hello World!');¬
  31. ▸ ▸ ▸ ▸ ▸ ▸ $block['content'] = $block_content;¬
  32. ▸ ▸ ▸ break;¬
  33. ▸ ▸ ▸ ▸ }¬
  34. return $block;¬
  35. ▸ ▸ }¬
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement